Add string terminators to some list functions; add concat
This commit is contained in:
parent
55f393b4f1
commit
1217fe951f
|
@ -10,6 +10,7 @@ memberOf?(x::xs, member) ->
|
|||
|
||||
-- map function: map(\x -> x*2, [1, 2, 3]) == [2, 4, 6]
|
||||
map(f, []) -> [].
|
||||
map(f, "") -> [].
|
||||
map(f, x::xs) -> f(x) :: map(f, xs).
|
||||
|
||||
-- list folds
|
||||
|
@ -38,6 +39,7 @@ filter(f, x::xs) ->
|
|||
-- index function
|
||||
-- out of values (hey, this isn't the Circus of Values!)
|
||||
at([], _) -> 0 - 1. -- (-1)
|
||||
at("", _) -> 0 - 1. -- (-1)
|
||||
-- we've hit our target item
|
||||
at(x::_, 0) -> x.
|
||||
-- we've got more to go, keep iterating
|
||||
|
|
|
@ -20,4 +20,7 @@ dropS(n, _::xs) -> dropS(n-1, xs).
|
|||
|
||||
takeS(0, _) -> "".
|
||||
takeS(n, "") -> "".
|
||||
takeS(n, x::xs) -> x :: takeS(n-1, xs).
|
||||
takeS(n, x::xs) -> x :: takeS(n-1, xs).
|
||||
|
||||
concat([]) -> "".
|
||||
concat(x :: xs) -> x + concat(xs).
|
||||
|
|
Loading…
Reference in New Issue