REBOL 3 Docs | Guide | Concepts | Functions | Datatypes | Errors |
TOC < Back Next > | Updated: 19-Aug-2010 Edit History |
Copies and removes from series. (Modifies)
Arguments:
value [series! port! gob! none!]
Refinements:
/part - Limits to a given length or position
length [number! series! pair!]
/deep - Also copies series values within the block
/last - Take it from the tail end
The take function removes a value from a series and returns it as the result. It's a useful combination of pick with remove.
For example, used on blocks:
data: [a b c d]
take data
a
probe data
[b c d]
Used on strings:
str: "abcd"
take str
#"a"
probe str
"bcd"
The take function is quite useful for making queues and stacks.
An example queue is implemented as first in first out (FIFO) block. New values are added with append and removed with take.
data: make block! 10
append data 1
append data 2
append data 3
take data
1
take data
2
An example stack is implemented as last in first out (LIFO). The difference is to use the /last refinement with take.
data: make block! 10
append data 1
append data 2
append data 3
take/last data
3
take/last data
2
The data queued and stacked above can be any REBOL values, including string, functions, objects or whatever.
TOC < Back Next > | REBOL.com - WIP Wiki | Feedback Admin |