summary refs log tree commit diff
path: root/pkgs/lib/lists.nix
diff options
context:
space:
mode:
authorNicolas Pierron <nicolas.b.pierron@gmail.com>2009-09-28 18:22:14 +0000
committerNicolas Pierron <nicolas.b.pierron@gmail.com>2009-09-28 18:22:14 +0000
commite6399964cb628b705a8acf52223c4fd99229a43c (patch)
tree5196836f03b150e0ded8c936f77d1c078ba498b2 /pkgs/lib/lists.nix
parentaf88789507a2384d7ffcaa2349418c50339c2217 (diff)
downloadnixpkgs-e6399964cb628b705a8acf52223c4fd99229a43c.tar
nixpkgs-e6399964cb628b705a8acf52223c4fd99229a43c.tar.gz
nixpkgs-e6399964cb628b705a8acf52223c4fd99229a43c.tar.bz2
nixpkgs-e6399964cb628b705a8acf52223c4fd99229a43c.tar.lz
nixpkgs-e6399964cb628b705a8acf52223c4fd99229a43c.tar.xz
nixpkgs-e6399964cb628b705a8acf52223c4fd99229a43c.tar.zst
nixpkgs-e6399964cb628b705a8acf52223c4fd99229a43c.zip
Add the zipLists and zipListsWith functions.
svn path=/nixpkgs/trunk/; revision=17476
Diffstat (limited to 'pkgs/lib/lists.nix')
-rw-r--r--pkgs/lib/lists.nix10
1 files changed, 9 insertions, 1 deletions
diff --git a/pkgs/lib/lists.nix b/pkgs/lib/lists.nix
index 012b95ad061..785e47e7d52 100644
--- a/pkgs/lib/lists.nix
+++ b/pkgs/lib/lists.nix
@@ -127,5 +127,13 @@ rec {
       else { right = t.right; wrong = [h] ++ t.wrong; }
     ) { right = []; wrong = []; };
 
-    
+
+  zipListsWith = f: fst: snd:
+    if fst != [] && snd != [] then
+      [ (f (head fst) (head snd)) ]
+      ++ zipLists (tail fst) (tail snd)
+    else [];
+
+  zipLists = zipListsWith (fst: snd: { inherit fst snd; });
+
 }