Advent-of-Nix-2024/utils.nix

13 lines
383 B
Nix
Raw Normal View History

2024-12-01 15:50:11 +01:00
{ lib, ... }:
with lib;
with builtins; rec {
2024-12-02 10:00:36 +01:00
readLines = f: init (filter isString (split "\n" (readFile f)));
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-02 10:00:36 +01:00
deleteAt = l: i: (take i l) ++ (drop (i+1) l);
2024-12-01 15:59:47 +01:00
eq = x: y: x == y;
2024-12-02 10:00:36 +01:00
greaterThan = x: y: x > y;
2024-12-01 15:50:11 +01:00
}