From e6399964cb628b705a8acf52223c4fd99229a43c Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Mon, 28 Sep 2009 18:22:14 +0000 Subject: [PATCH] Add the zipLists and zipListsWith functions. svn path=/nixpkgs/trunk/; revision=17476 --- pkgs/lib/lists.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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; }); + }