* 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:
Eelco Dolstra 2009-06-08 22:42:42 +00:00
parent ff715fa8ed
commit 6408a6a6fd

View file

@ -4,6 +4,12 @@ rec {
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
# `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