meta: refactor

This commit is contained in:
Max Headroom 2022-12-03 13:14:36 +01:00
parent 1a65daf518
commit 8fb824e33c
3 changed files with 7 additions and 5 deletions

View file

@ -11,5 +11,5 @@ pipe input [
(map toInt) (map toInt)
sum sum
])) ]))
(foldl' max 0) (foldl1 max)
] ]

View file

@ -15,7 +15,7 @@ pipe input [
(groupwise 3) (groupwise 3)
(map (flip pipe [ (map (flip pipe [
(map strings.stringToCharacters) (map strings.stringToCharacters)
(l: foldl' intersectLists (head l) l) (foldl1 intersectLists)
head head
prio prio
])) ]))

View file

@ -1,7 +1,9 @@
let let
nixpkgsLib = import <nixpkgs/lib>; nixpkgsLib = import <nixpkgs/lib>;
aocLib = with nixpkgsLib; rec { aocLib = self: with self; nixpkgsLib // {
foldl1 = f: xs: foldl' f (head xs) (tail xs);
groupwise = size: l: let groupwise = size: l: let
rest = drop size l; rest = drop size l;
in [ (take size l) ] ++ optionals (rest != []) (groupwise size rest); in [ (take size l) ] ++ optionals (rest != []) (groupwise size rest);
@ -11,8 +13,8 @@ let
(filter isString) (filter isString)
]; ];
sum = foldl' add 0; sum = foldl1 add;
unpackAttrsCall = f: attrs: f attrs.a attrs.b; unpackAttrsCall = f: attrs: f attrs.a attrs.b;
}; };
in nixpkgsLib // aocLib in nixpkgsLib.fix aocLib