Advent-of-Nix-2024/utils.nix
2024-12-01 16:19:19 +01:00

10 lines
346 B
Nix

{ lib, ... }:
with lib;
with builtins; rec {
readLines = f: let lines = filter isString (split "\n" (readFile f)); in take ((length lines) - 1) lines;
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;
eq = x: y: x == y;
}