* Trivial function to create a singleton list. Can reduce unnecessary
indentation in expressions like environent.extraJobs = [ { name = "foo"; job = '' bla bla ''; } ]; which becomes environent.extraJobs = singleton { name = "foo"; job = '' bla bla ''; }; svn path=/nixpkgs/trunk/; revision=15892
This commit is contained in:
parent
ff715fa8ed
commit
6408a6a6fd
@ -4,6 +4,12 @@ rec {
|
|||||||
inherit (builtins) head tail isList;
|
inherit (builtins) head tail isList;
|
||||||
|
|
||||||
|
|
||||||
|
# Create a list consisting of a single element. `singleton x' is
|
||||||
|
# sometimes more convenient with respect to indentation than `[x]'
|
||||||
|
# when x spans multiple lines.
|
||||||
|
singleton = x: [x];
|
||||||
|
|
||||||
|
|
||||||
# "Fold" a binary function `op' between successive elements of
|
# "Fold" a binary function `op' between successive elements of
|
||||||
# `list' with `nul' as the starting value, i.e., `fold op nul [x_1
|
# `list' with `nul' as the starting value, i.e., `fold op nul [x_1
|
||||||
# x_2 ... x_n] == op x_1 (op x_2 ... (op x_n nul))'. (This is
|
# x_2 ... x_n] == op x_1 (op x_2 ... (op x_n nul))'. (This is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user