diff --git a/1/basic.nix b/1/basic.nix index 477b4f9..4e19a94 100644 --- a/1/basic.nix +++ b/1/basic.nix @@ -11,5 +11,5 @@ pipe input [ (map toInt) sum ])) - (foldl' max 0) + (foldl1 max) ] diff --git a/3/advanced.nix b/3/advanced.nix index 85b498a..3ea47ef 100644 --- a/3/advanced.nix +++ b/3/advanced.nix @@ -15,7 +15,7 @@ pipe input [ (groupwise 3) (map (flip pipe [ (map strings.stringToCharacters) - (l: foldl' intersectLists (head l) l) + (foldl1 intersectLists) head prio ])) diff --git a/lib/default.nix b/lib/default.nix index 6fe3cb6..9766ecf 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,7 +1,9 @@ let nixpkgsLib = import ; - aocLib = with nixpkgsLib; rec { + aocLib = self: with self; nixpkgsLib // { + foldl1 = f: xs: foldl' f (head xs) (tail xs); + groupwise = size: l: let rest = drop size l; in [ (take size l) ] ++ optionals (rest != []) (groupwise size rest); @@ -11,8 +13,8 @@ let (filter isString) ]; - sum = foldl' add 0; + sum = foldl1 add; unpackAttrsCall = f: attrs: f attrs.a attrs.b; }; -in nixpkgsLib // aocLib +in nixpkgsLib.fix aocLib