From d7acaeb0969bf6d5d4be83ca23fd2e86baf8eba5 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Wed, 20 Aug 2008 11:20:32 +0000 Subject: Refactorings and removing hard-coded assumptions svn path=/nixpkgs/trunk/; revision=12668 --- pkgs/lib/default.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'pkgs/lib') diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix index ecbe18dfa7e42..8b5548bd6d826 100644 --- a/pkgs/lib/default.nix +++ b/pkgs/lib/default.nix @@ -32,20 +32,21 @@ rec { else (innerComposedArgs f (y x)))); composedArgs = f: innerComposedArgs f {}; - defaultMerge = x : y: if builtins.isAttrs y then - x // y + defaultMergeArg = x : y: if builtins.isAttrs y then + y else - y x; + (y x); + defaultMerge = x: y: x // (defaultMergeArg x y); sumTwoArgs = f: x: y: f (defaultMerge x y); foldArgs = merger: f: init: x: - let arg=(merger init (defaultMerge init x)); in + let arg=(merger init (defaultMergeArg init x)); in (f arg) // { meta = { 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"]; # result: ["ab" "cd"] -- cgit 1.4.1