advent-of-code/2020/src/input_helpers.nim

8 lines
214 B
Nim

import streams, strutils, sugar
iterator mapStream*[T](s: Stream, cb: (string) -> T): T =
for line in s.lines(): yield cb line
iterator asInts*(s: Stream): int =
for i in mapStream[int](s, parseInt): yield i