Refactorings and removing hard-coded assumptions
svn path=/nixpkgs/trunk/; revision=12668
This commit is contained in:
parent
a921f752b8
commit
d7acaeb096
@ -32,20 +32,21 @@ 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
|
defaultMergeArg = x : y: if builtins.isAttrs y then
|
||||||
x // y
|
y
|
||||||
else
|
else
|
||||||
y x;
|
(y x);
|
||||||
|
defaultMerge = x: y: x // (defaultMergeArg x y);
|
||||||
sumTwoArgs = f: x: y:
|
sumTwoArgs = f: x: y:
|
||||||
f (defaultMerge x y);
|
f (defaultMerge x y);
|
||||||
foldArgs = merger: f: init: x:
|
foldArgs = merger: f: init: x:
|
||||||
let arg=(merger init (defaultMerge init x)); in
|
let arg=(merger init (defaultMergeArg init x)); in
|
||||||
(f arg) // {
|
(f arg) // {
|
||||||
meta = {
|
meta = {
|
||||||
function = foldArgs merger f arg;
|
function = foldArgs merger f arg;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
composedArgsAndFun = f: foldArgs (x: y: y) f {};
|
composedArgsAndFun = f: foldArgs defaultMerge 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…
x
Reference in New Issue
Block a user