Files
kiss-vscode/projects/aoc/src/Util.kiss
2022-06-18 20:35:57 +00:00

23 lines
750 B
Plaintext

(function readLines [file]
(filter
(.map
(.split (.replace (File.getContent file) "\r" "") "\n")
StringTools.trim)))
(function readParagraphLines [file]
(.filter
(for paragraph
(.split
(.replace (File.getContent file) "\r" "")
"\n\n")
(.filter
(paragraph.split "\n")
(lambda [line] (< 0 line.length))))
(lambda [lines] (< 0 lines.length))))
// TODO won't need to specify type here if last is not a quickNth
(function :kiss.List<Int> readInts [file] (let [lines (readLines file)] (lines.map Std.parseInt)))
(function countChar [char str]
(count (str.split "") (lambda [c] ?(= c char))))