mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
2ab4bc44c7
* Put common test functions in tests/lang/lib.nix.
18 lines
314 B
Nix
18 lines
314 B
Nix
rec {
|
|
|
|
fold = op: nul: list:
|
|
if list == []
|
|
then nul
|
|
else op (builtins.head list) (fold op nul (builtins.tail list));
|
|
|
|
concat =
|
|
fold (x: y: x + y) "";
|
|
|
|
flatten = x:
|
|
if builtins.isList x
|
|
then fold (x: y: (flatten x) ++ y) [] x
|
|
else [x];
|
|
|
|
sum = fold (x: y: builtins.add x y) 0;
|
|
|
|
}
|