mirror of
https://github.com/antirez/aocla
synced 2024-12-27 09:58:32 +01:00
21 lines
385 B
Text
21 lines
385 B
Text
// Fundamental list manipulation functions. Part of the standard library.
|
|
// first, rest, cat
|
|
|
|
[
|
|
0 get@
|
|
] 'first def
|
|
|
|
[
|
|
#t (f) // True only for the first element
|
|
[] (n) // New list
|
|
[
|
|
[$f] [
|
|
#f (f) // Set flag to false
|
|
drop // Discard first element
|
|
] [
|
|
$n -> (n)
|
|
] ifelse
|
|
] foreach
|
|
$n
|
|
] 'rest def
|
|
|