advent-of-code/2019/common.moon

17 lines
258 B
Plaintext
Raw Normal View History

2019-12-01 14:49:58 -06:00
export input_for_day, reduce
read_whole_file = =>
f = assert io.open @, "rb"
content = f\read "*all"
f\close()
content
input_for_day = =>
read_whole_file "input/#{@}.txt"
2019-12-01 14:55:48 -06:00
reduce = (initial, f) =>
2019-12-01 14:49:58 -06:00
acc = initial
2019-12-01 14:55:48 -06:00
for e in @
2019-12-01 14:49:58 -06:00
acc = f acc, e
acc