added Haskell's foldl
svn path=/nixpkgs/trunk/; revision=13553
This commit is contained in:
parent
0b49861c7b
commit
9e7846d214
@ -96,6 +96,12 @@ rec {
|
|||||||
then nul
|
then nul
|
||||||
else op (head list) (fold op nul (tail list));
|
else op (head list) (fold op nul (tail list));
|
||||||
|
|
||||||
|
# Haskell's fold
|
||||||
|
foldl = op: nul: list:
|
||||||
|
if list == []
|
||||||
|
then nul
|
||||||
|
else fold op (op nul (head list)) (tail list);
|
||||||
|
|
||||||
|
|
||||||
# Concatenate a list of lists.
|
# Concatenate a list of lists.
|
||||||
concatList = x : y : x ++ y;
|
concatList = x : y : x ++ y;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user