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

svn path=/nixpkgs/trunk/; revision=19179
This commit is contained in:
Nicolas Pierron 2010-01-03 11:05:42 +00:00
parent ab1eec6a60
commit d311b4e98f

View file

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