* 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
wip/yesman
Eelco Dolstra 15 years ago
parent ff715fa8ed
commit 6408a6a6fd
  1. 6
      pkgs/lib/lists.nix

@ -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

Loading…
Cancel
Save