Rejoining a block – rejoin

In the Evaluation with do and reduce section in Chapter 3, Using Words, Values, and Types, we saw how reduce evaluates expressions within a block, returning that block. The rejoin word goes one step further—it not only reduces a block, but it also joins the items in the block into a string with no spaces in between them. It returns the rejoined item, but the original series is not changed. It's like form, but with evaluation. Here are some examples of this:

ser: ["Product is: " 7 * 42]rejoin ser   ;== "Product is: 294"ser          ;== ["Product is: " 7 * 42]

Because rejoin converts a block into a string, it is often used in output print statements, such as print rejoin [newline "Total Images: " count] .

Get Learn Red - Fundamentals of Red now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.