diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-09-22T14·46+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-09-22T14·46+0000 |
commit | c02a44183fcff7c28cfed1c84c142cc2cf80f167 (patch) | |
tree | a22e8e94ab228480141ece3354c7c91602b5a47b /tests | |
parent | 8a1ab709a47f0896cb5b47521e31c8c27f88b2b3 (diff) |
* 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).
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lang/eval-okay-list.exp | 1 | ||||
-rw-r--r-- | tests/lang/eval-okay-list.nix | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tests/lang/eval-okay-list.exp b/tests/lang/eval-okay-list.exp new file mode 100644 index 000000000000..369d34641f26 --- /dev/null +++ b/tests/lang/eval-okay-list.exp @@ -0,0 +1 @@ +Str("foobarblatest") diff --git a/tests/lang/eval-okay-list.nix b/tests/lang/eval-okay-list.nix new file mode 100644 index 000000000000..72a120d0d0f2 --- /dev/null +++ b/tests/lang/eval-okay-list.nix @@ -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"]; + +} \ No newline at end of file |