Optimize list intersection
This commit is contained in:
parent
cd80733367
commit
6b3d803456
5
util.nix
5
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user