diff options
author | Vladimír Čunát <vcunat@gmail.com> | 2017-07-02 09:32:43 +0200 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2017-07-07 12:02:29 -0400 |
commit | dfc004e69c23cb48cce2c7537169a81b299a0af9 (patch) | |
tree | b297211c5ec12a3882e0940925687d74e4ae53ef /lib | |
parent | 5afcdc88fa7ce9583eecec136de49685923e8df7 (diff) |
lib.lists.mutuallyExclusive: add function
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lists.nix | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/lists.nix b/lib/lists.nix index a04b1b278935..6a8fd8a18408 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -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); + } |