Advent-of-Nix-2024/utils.nix
2024-12-02 10:00:36 +01:00

12 lines
383 B
Nix

{ lib, ... }:
with lib;
with builtins; rec {
readLines = f: init (filter isString (split "\n" (readFile f)));
splitWhitespace = s: filter isString (builtins.split "[[:space:]]+" s);
abs = i: if i >= 0 then i else i * -1;
delta = x: y: abs (x - y);
listSum = foldl' add 0;
deleteAt = l: i: (take i l) ++ (drop (i+1) l);
eq = x: y: x == y;
greaterThan = x: y: x > y;
}