forked from mirrors/nixpkgs
* Add a function to take the last element of a list.
svn path=/nixpkgs/trunk/; revision=19179
This commit is contained in:
parent
ab1eec6a60
commit
d311b4e98f
|
@ -167,4 +167,9 @@ rec {
|
||||||
if list == [] || count == 0 then []
|
if list == [] || count == 0 then []
|
||||||
else [ (head list) ] ++ take (builtins.sub count 1) (tail list);
|
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…
Reference in a new issue