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)
sum
]))
(foldl' max 0)
(foldl1 max)
]

View file

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

View file

@ -1,7 +1,9 @@
let
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
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