1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-10 04:43:53 +02:00

* Added a builtin function `isList' to test whether a value is a list.

With this primitive, a list-flattening function can be implemented
  (NIX-55, example is in tests/lang/eval-okay-flatten.nix).
This commit is contained in:
Eelco Dolstra 2006-09-22 14:55:19 +00:00
parent c02a44183f
commit d315210612
3 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1 @@
Str("1234567")

View file

@ -0,0 +1,19 @@
let {
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];
l = ["1" "2" ["3" ["4"] ["5" "6"]] "7"];
body = concat (flatten l);
}