Skip to Content
Learn Red ? Fundamentals of Red
book

Learn Red ? Fundamentals of Red

by Ivo Balbaert
May 2018
Beginner content levelBeginner
252 pages
6h 19m
English
Packt Publishing
Content preview from Learn Red ? Fundamentals of Red

Deleting items – remove and take

To delete the first item in a series, use remove:

remove [10 11 12] ;== [11 12]

The take word does the same, but returns that item instead of the changed series:

take [10 11 12] ;== 10

To delete an item at a certain position, use at, the same way as we did with insert:

s: [0 1 2 3 4 5]   ;== [0 1 2 3 4 5]remove at s 2      ;== [2 3 4 5] s                  ;== [0 2 3 4 5]   ; item 1 at position 2 is deleted

To delete the last item of a series, you could use remove at s length? s, but take/last does the same thing and returns that last item as well:

take/last [10 11 12] ;== 12

To delete a certain number of items, use /part:

remove/part [10 11 12] 2    ;== [12]

The take/part phrase has the same effect on a series, but returns ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

How I Built a Personal Board of Directors With GenAI

How I Built a Personal Board of Directors With GenAI

Vipin Gupta
How to Become a Game-Changing Leader

How to Become a Game-Changing Leader

Douglas A. Ready, Alan Mulally
Why AI Demands a New Breed of Leaders

Why AI Demands a New Breed of Leaders

Faisal Hoque, Thomas Davenport, Erik Nelson

Publisher Resources

ISBN: 9781789130706Supplemental Content