lib.lists.mutuallyExclusive: add function

This commit is contained in:
Vladimír Čunát
2017-07-07 12:02:29 -04:00
committed by John Ericson
parent 5afcdc88fa
commit dfc004e69c
2 changed files with 9 additions and 6 deletions
+8
View File
@@ -477,4 +477,12 @@ rec {
*/
subtractLists = e: filter (x: !(elem x e));
/* Test if two lists have no common element.
It should be slightly more efficient than (intersectLists a b == [])
*/
mutuallyExclusive = a: b:
(builtins.length a) == 0 ||
(!(builtins.elem (builtins.head a) b) &&
mutuallyExclusive (builtins.tail a) b);
}