Noticed an associativity direction problem

svn path=/nixpkgs/trunk/; revision=12664
This commit is contained in:
Michael Raskin 2008-08-20 06:45:14 +00:00
parent 69e4f17372
commit 97e15cc2b8

View File

@ -32,16 +32,20 @@ rec {
else (innerComposedArgs f (y x)))); else (innerComposedArgs f (y x))));
composedArgs = f: innerComposedArgs f {}; composedArgs = f: innerComposedArgs f {};
sumTwoArgs = f: x: y: defaultMerge = x : y: if builtins.isAttrs y then
if builtins.isAttrs y then x // y
(f (x // y))
else else
(f (y x)); y x;
composedArgsAndFun = f : x : (f x) // { sumTwoArgs = f: x: y:
f (defaultMerge x y);
foldArgs = merger: f: init: x:
let arg=(merger init (defaultMerge init x)); in
(f arg) // {
meta = { meta = {
function = composedArgsAndFun (sumTwoArgs f x); function = foldArgs merger f arg;
}; };
}; };
composedArgsAndFun = f: foldArgs (x: y: y) {} f;
# example a = pairMap (x : y : x + y) ["a" "b" "c" "d"]; # example a = pairMap (x : y : x + y) ["a" "b" "c" "d"];
# result: ["ab" "cd"] # result: ["ab" "cd"]