cascade-functions/take.nix

12 lines
249 B
Nix
Raw Permalink Normal View History

2022-10-16 22:46:24 +00:00
with builtins;
let take' = take': n: l:
if n < 0 then throw "take requires a positive whole number or 0." else
if n == 0 || l == []
then []
else [ (head l) ] ++ (take' take' (n - 1) (tail l));
take = take' take';
in
take