Moving items – move and swap

To move the first item from one series to another, use the move word:

s: ["A" "B" "C"]move [1 2 3] s    ;== [2 3]s                 ;== [1 "A" "B" "C"]

It returns the changed first series, but, as you can see, the second series is also changed. To move a number of items, use /part again in the code phrase move/part series1 series2 number.

=> Now answer question 11 from the Questions section.

Use swap to swap the first element(s) of two series. It returns the first series, but changes both:

swap [A B C][1 2 3] ;== [1 B C]

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.