Noticed an associativity direction problem
svn path=/nixpkgs/trunk/; revision=12664
This commit is contained in:
parent
69e4f17372
commit
97e15cc2b8
|
@ -32,16 +32,20 @@ rec {
|
||||||
else (innerComposedArgs f (y x))));
|
else (innerComposedArgs f (y x))));
|
||||||
composedArgs = f: innerComposedArgs f {};
|
composedArgs = f: innerComposedArgs f {};
|
||||||
|
|
||||||
|
defaultMerge = x : y: if builtins.isAttrs y then
|
||||||
|
x // y
|
||||||
|
else
|
||||||
|
y x;
|
||||||
sumTwoArgs = f: x: y:
|
sumTwoArgs = f: x: y:
|
||||||
if builtins.isAttrs y then
|
f (defaultMerge x y);
|
||||||
(f (x // y))
|
foldArgs = merger: f: init: x:
|
||||||
else
|
let arg=(merger init (defaultMerge init x)); in
|
||||||
(f (y x));
|
(f arg) // {
|
||||||
composedArgsAndFun = f : x : (f x) // {
|
meta = {
|
||||||
meta = {
|
function = foldArgs merger f arg;
|
||||||
function = composedArgsAndFun (sumTwoArgs f x);
|
};
|
||||||
};
|
};
|
||||||
};
|
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"]
|
||||||
|
|
Loading…
Reference in a new issue