'head' [
'get the first element of a list' [
(1 2 3 4) head
1 =
] can
'ignore an empty list' [
() head nil?
] can
] describe
'tail' [
'get all items from a list excluding its head' [
(1 2 3 4) tail
(2 3 4) =
] can
'ignore an empty list' [
() tail nil?
] can
] describe
'cons' [
'add an element to a list' [
() 1 cons 2 cons 3 cons
(1 2 3) =
] can
] describe
'append' [
'add two lists together' [
(4 5 6) (1 2 3) append
(1 2 3 4 5 6) =
] can
] describe
'prepend' [
'add two lists together' [
(1 2 3) (4 5 6) prepend
(1 2 3 4 5 6) =
] can
] describe
'apply' [
'call the block on the list' [
(1 2 3) :swap apply
(1 3 2) =
] can
] describe
'reverse' [
'reverse the list' [
(1 2 3) reverse
(3 2 1) =
] can
] describe
'reduce' [
'apply a block to each pair of elements in the list' [
(1 2 3 4) :+ reduce
10 =
] can
] describe
'map' [
'apply a block to each element in the list' [
(1 2 3 4) :inc map
(2 3 4 5) =
] can
] describe