Selecting an item – pick and /

We can select an item in two ways, using our data: [A B C D] series:

  • By specifying the item index in a so-called path notation, such as data/3 ;== C
  • By specifying the item index with pick, such as pick data 3 ;== C

=> Now answer question 6 from the Questions section.

If the item index is a variable, here represented by i, you need to use the :i get word notation:

i: 3data/:i      ;== Cdata/(i)     ;== C   ; this alternative works also
This is important to remember, because data/i doesn't give any error, but returns none. When the specified index is out of range, no error is generated, and the result is also none, for example, pick data 100 ;== none.

Strings are also series, so pick and / work for strings as well, with ...

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.