* Add a function to take the last element of a list.

svn path=/nixpkgs/trunk/; revision=19179
wip/yesman
Nicolas Pierron 15 years ago
parent ab1eec6a60
commit d311b4e98f
  1. 5
      pkgs/lib/lists.nix

@ -167,4 +167,9 @@ rec {
if list == [] || count == 0 then []
else [ (head list) ] ++ take (builtins.sub count 1) (tail list);
last = list:
assert list != [];
let loop = l: if tail l == [] then head l else loop (tail l); in
loop list;
}

Loading…
Cancel
Save