From 6b3d803456b13ef032959b0165de24e1dd55ccbc Mon Sep 17 00:00:00 2001 From: zuckerberg <5-zuckerberg@users.noreply.git.neet.dev> Date: Mon, 5 Dec 2022 13:08:13 -0700 Subject: [PATCH] Optimize list intersection --- util.nix | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/util.nix b/util.nix index 0e35c09..831b26c 100644 --- a/util.nix +++ b/util.nix @@ -20,10 +20,7 @@ let [(take cnt l)] ++ chunksOf cnt (drop cnt l) else []; # same as intersectLists but takes an array of lists to intersect instead of just two - intersectManyLists = l: - if length l == 0 then [] - else if length l == 1 then head l - else intersectLists (head l) (intersectManyLists (tail l)); + intersectManyLists = ll: foldr intersectLists (head ll) ll; # converts a boolean to a int (c style) boolToInt = b: if b then 1 else 0; # drops the last element of a list