From beee6e5e1d1ab456a162de827440cd4890514a2b Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Mon, 2 Aug 2010 16:10:01 +0000 Subject: [PATCH] Moved 'zip' function from nixos/lib/build-vms.nix svn path=/nixpkgs/trunk/; revision=22882 --- pkgs/lib/lists.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/lib/lists.nix b/pkgs/lib/lists.nix index 9b8334a5b9df..e279d6a80f47 100644 --- a/pkgs/lib/lists.nix +++ b/pkgs/lib/lists.nix @@ -177,4 +177,10 @@ rec { let loop = l: if tail l == [] then head l else loop (tail l); in loop list; + # Zip two lists together. + zip = xs: ys: + if xs != [] && ys != [] then + [ {first = head xs; second = head ys;} ] + ++ zip (tail xs) (tail ys) + else []; }