1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 01:51:47 +02:00

* Builtin functions head' and tail' to return the head and tail of

list.  Useful for lots of things, such as implementing a fold
  function (see NIX-30, example is in tests/lang/eval-okay-list.nix).
This commit is contained in:
Eelco Dolstra 2006-09-22 14:46:36 +00:00
parent 8a1ab709a4
commit c02a44183f
3 changed files with 39 additions and 0 deletions

View file

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

View file

@ -0,0 +1,13 @@
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) "";
body = concat ["foo" "bar" "bla" "test"];
}