diff options
author | Marc Weber <marco-oweber@gmx.de> | 2009-12-08 21:47:14 +0000 |
---|---|---|
committer | Marc Weber <marco-oweber@gmx.de> | 2009-12-08 21:47:14 +0000 |
commit | 7ef915ebc88f7784cdec5a9917818cbdfe1a76c4 (patch) | |
tree | 9f6d92bd9b8d7e9ed1810443038c3a548ae186a1 /pkgs/lib/lists.nix | |
parent | 89b59e3fbcf1cce419e9badfdb885484b429953a (diff) | |
download | nixpkgs-7ef915ebc88f7784cdec5a9917818cbdfe1a76c4.tar nixpkgs-7ef915ebc88f7784cdec5a9917818cbdfe1a76c4.tar.gz nixpkgs-7ef915ebc88f7784cdec5a9917818cbdfe1a76c4.tar.bz2 nixpkgs-7ef915ebc88f7784cdec5a9917818cbdfe1a76c4.tar.lz nixpkgs-7ef915ebc88f7784cdec5a9917818cbdfe1a76c4.tar.xz nixpkgs-7ef915ebc88f7784cdec5a9917818cbdfe1a76c4.tar.zst nixpkgs-7ef915ebc88f7784cdec5a9917818cbdfe1a76c4.zip |
nixpkgs lib: adding haskell's take
svn path=/nixpkgs/trunk/; revision=18848
Diffstat (limited to 'pkgs/lib/lists.nix')
-rw-r--r-- | pkgs/lib/lists.nix | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pkgs/lib/lists.nix b/pkgs/lib/lists.nix index 3a5ed2628de..4359662da27 100644 --- a/pkgs/lib/lists.nix +++ b/pkgs/lib/lists.nix @@ -161,4 +161,10 @@ rec { in qs list []; + + # haskell's take: take 2 [1 2 3 4] yields [1 2] + take = count: list: + if list == [] || count == 0 then [] + else [ (head list) ] ++ take (builtins.sub count 1) (tail list); + } |