19 lines
636 B
Nix
19 lines
636 B
Nix
|
|
let
|
|
lib = import <nixpkgs/lib>;
|
|
utils = rec {
|
|
# Passthrough trace for debugging
|
|
pTrace = v: lib.traceSeq v v;
|
|
# find the total sum of a int list
|
|
sum = l: lib.foldr (x: y: x + y) 0 l;
|
|
# 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);
|
|
# Finds the max value in a list
|
|
maxList = l: lib.foldr lib.max 0 l;
|
|
# Sorts a int list. Greatest value first
|
|
sortList = l: lib.sort (x: y: x > y) l;
|
|
# Returns the top cnt items of the list
|
|
topOfList = l: cnt: lib.take cnt l;
|
|
};
|
|
in
|
|
lib // lib.strings // builtins // utils |