From 01b972fe3d5046a3f707104554726b86b99c3c22 Mon Sep 17 00:00:00 2001 From: zuckerberg <5-zuckerberg@users.noreply.git.neet.dev> Date: Sat, 3 Dec 2022 20:06:30 -0700 Subject: [PATCH] Remove need to specify lib --- util.nix | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/util.nix b/util.nix index f8cd00c..6645a19 100644 --- a/util.nix +++ b/util.nix @@ -1,30 +1,29 @@ let lib = import ; - utils = rec { - inherit lib; + utils = with lib; rec { # Passthrough trace for debugging - pTrace = v: lib.traceSeq v v; + pTrace = v: traceSeq v v; # find the total sum of a int list - sum = lib.foldr (x: y: x + y) 0; + sum = foldr (x: y: x + y) 0; # splits a list of length two into two params then they're passed to a func - split = pair: f: f (lib.head pair) (lib.last pair); + split = pair: f: f (head pair) (last pair); # Finds the max value in a list - maxList = lib.foldr lib.max 0; + maxList = foldr max 0; # Sorts a int list. Greatest value first - sortList = lib.sort (x: y: x > y); + sortList = sort (x: y: x > y); # Cuts a list in half and returns the two parts in a list - cutInHalf = l: [(lib.take (lib.length l / 2) l) (lib.drop (lib.length l / 2) l)]; + cutInHalf = l: [(take (length l / 2) l) (drop (length l / 2) l)]; # Splits a list into a list of lists with length cnt chunksOf = cnt: l: - if lib.length l >= cnt then - [(lib.take cnt l)] ++ chunksOf cnt (lib.drop cnt l) + if length l >= cnt then + [(take cnt l)] ++ chunksOf cnt (drop cnt l) else []; # same as intersectLists but takes an array of lists to intersect instead of just two intersectManyLists = l: - if lib.length l == 0 then [] - else if lib.length l == 1 then lib.head l - else lib.intersectLists (lib.head l) (intersectManyLists (lib.tail l)); + if length l == 0 then [] + else if length l == 1 then head l + else intersectLists (head l) (intersectManyLists (tail l)); }; in lib // lib.strings // builtins // utils \ No newline at end of file