insert

To add a new item into the series itself, use insert, which inserts the item at the current index (as you know, this is given by index? and can be changed by at). For a newly defined series, insert will occur at the start of the series:

s: [10 11 12]  ;== [10 11 12]insert s 13    ;== [10 11 12]s              ;== [13 10 11 12]

Here, you can see that insert returns the series after the insertion. But insert changes the series s as well so that you don't have to use s: insert s 13

To specify the insert position, use at:

s: [10 11 12]      ;== [10 11 12]insert at s 2 13   ;== [11 12]s                  ;== [10 13 11 12]

The insert word has the same refinements as append.

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.