about summary refs log tree commit diff
path: root/pkgs/lib
diff options
context:
space:
mode:
authorMarc Weber <marco-oweber@gmx.de>2008-01-17 01:31:07 +0000
committerMarc Weber <marco-oweber@gmx.de>2008-01-17 01:31:07 +0000
commit42dd0cdac8d74196de6bacc9607913a1e5e909db (patch)
treec2ffcb6fd7a3a051fbd4ee2e5f25319e9028b3d6 /pkgs/lib
parent817d45cb232d941b5cf09e14757ad2dd5ee092be (diff)
downloadnixlib-42dd0cdac8d74196de6bacc9607913a1e5e909db.tar
nixlib-42dd0cdac8d74196de6bacc9607913a1e5e909db.tar.gz
nixlib-42dd0cdac8d74196de6bacc9607913a1e5e909db.tar.bz2
nixlib-42dd0cdac8d74196de6bacc9607913a1e5e909db.tar.lz
nixlib-42dd0cdac8d74196de6bacc9607913a1e5e909db.tar.xz
nixlib-42dd0cdac8d74196de6bacc9607913a1e5e909db.tar.zst
nixlib-42dd0cdac8d74196de6bacc9607913a1e5e909db.zip
added some comments/examples (sumArgs, pairMap, whenFlip)
svn path=/nixpkgs/trunk/; revision=10184
Diffstat (limited to 'pkgs/lib')
-rw-r--r--pkgs/lib/default.nix8
1 files changed, 5 insertions, 3 deletions
diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix
index 21c48e9017bf..7c3cc1fe4fc1 100644
--- a/pkgs/lib/default.nix
+++ b/pkgs/lib/default.nix
@@ -15,11 +15,15 @@ rec {
   id = x: x;
 
 
-  # !!! need documentation...
+  # accumulates / merges all attr sets until null is fed.
+  # example: sumArgs id { a = 'a'; x = 'x'; } { y = 'y'; x = 'X'; } null
+  # result : { a = 'a'; x = 'X'; y = 'Y'; }
   innerSumArgs = f : x : y : (if y == null then (f x)
 	else (innerSumArgs f (x // y)));
   sumArgs = f : innerSumArgs f {};
 
+  # example a = pairMap (x : y : x + y) ["a" "b" "c" "d"];
+  # result: ["ab" "cd"]
   innerPairMap = acc: f: l: 
   	if l == [] then acc else
 	innerPairMap (acc ++ [(f (head l)(head (tail l)))])
@@ -314,8 +318,6 @@ rec {
   # calls a function (f attr value ) for each record item. returns a list
   mapRecordFlatten = f : r : map (attr: f attr (builtins.getAttr attr r) ) (attrNames r);
 
-  whenFlip = x : cond : if (cond) then x else "";
-
   # to be used with listToAttrs (_a_ttribute _v_alue)
   # TODO should be renamed to nv because niksnut has renamed the attribute attr to name
   av = name : value : { inherit name value; };