summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2007-10-03 13:26:24 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2007-10-03 13:26:24 +0000
commit33238a2bbf01df4b1067702edb014651d01d6c44 (patch)
treeaedc8cd485ab580b21a28d28a8b02ed23e32812e
parent459b386ff92561a0c26c342e50b85300b0242d62 (diff)
downloadnixpkgs-33238a2bbf01df4b1067702edb014651d01d6c44.tar
nixpkgs-33238a2bbf01df4b1067702edb014651d01d6c44.tar.gz
nixpkgs-33238a2bbf01df4b1067702edb014651d01d6c44.tar.bz2
nixpkgs-33238a2bbf01df4b1067702edb014651d01d6c44.tar.lz
nixpkgs-33238a2bbf01df4b1067702edb014651d01d6c44.tar.xz
nixpkgs-33238a2bbf01df4b1067702edb014651d01d6c44.tar.zst
nixpkgs-33238a2bbf01df4b1067702edb014651d01d6c44.zip
* findSingle: return a caller-specified value if there are multiple
  matching elements in the list.

svn path=/nixpkgs/trunk/; revision=9397
-rw-r--r--pkgs/lib/default.nix8
1 files changed, 4 insertions, 4 deletions
diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix
index a06090e76be..1a5dddecdfe 100644
--- a/pkgs/lib/default.nix
+++ b/pkgs/lib/default.nix
@@ -76,12 +76,12 @@ rec {
 
 
   # Find the sole element in the list matching the specified
-  # predicate, or returns the default value.
-  findSingle = pred: default: list:
+  # predicate, returns `default' if no such element exists, or
+  # `multiple' if there are multiple matching elements.
+  findSingle = pred: default: multiple: list:
     let found = filter pred list;
     in if found == [] then default
-       else if tail found != [] then
-         abort "Multiple elements match predicate in findSingle."
+       else if tail found != [] then multiple
        else head found;