Advent-of-Nix-2024/utils.nix

11 lines
312 B
Nix
Raw Normal View History

2024-12-01 15:50:11 +01:00
{ lib, ... }:
with lib;
with builtins; rec {
readLines = f: filter (s: (isString s) && s != "") (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);
noop = x: x;
listSum = foldl' add 0;
}