Advent-of-Nix-2024/utils.nix

11 lines
346 B
Nix
Raw Normal View History

2024-12-01 15:50:11 +01:00
{ lib, ... }:
with lib;
with builtins; rec {
2024-12-01 16:19:19 +01:00
readLines = f: let lines = filter isString (split "\n" (readFile f)); in take ((length lines) - 1) lines;
2024-12-01 15:50:11 +01:00
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;
2024-12-01 15:59:47 +01:00
eq = x: y: x == y;
2024-12-01 15:50:11 +01:00
}