use call-with-input-file
This commit is contained in:
14
day-2.scm
14
day-2.scm
@@ -5,7 +5,9 @@
|
|||||||
(list->string (reverse w))
|
(list->string (reverse w))
|
||||||
(loop (cons c w))))))
|
(loop (cons c w))))))
|
||||||
|
|
||||||
(let [(file (open-input-file "day-2.input"))]
|
(call-with-input-file
|
||||||
|
"day-2.input"
|
||||||
|
(lambda (file)
|
||||||
(let loop [(x 0) (y 0)]
|
(let loop [(x 0) (y 0)]
|
||||||
(let [(amount (string->number (get-word file)))
|
(let [(amount (string->number (get-word file)))
|
||||||
(move (get-word file))]
|
(move (get-word file))]
|
||||||
@@ -19,10 +21,11 @@
|
|||||||
(else
|
(else
|
||||||
(display "part 1: ")
|
(display "part 1: ")
|
||||||
(display (* x y))
|
(display (* x y))
|
||||||
(newline)
|
(newline)))))))
|
||||||
(close-port file))))))
|
|
||||||
|
|
||||||
(let [(file (open-input-file "day-2.input"))]
|
(call-with-input-file
|
||||||
|
"day-2.input"
|
||||||
|
(lambda (file)
|
||||||
(let loop [(x 0) (y 0) (aim 0)]
|
(let loop [(x 0) (y 0) (aim 0)]
|
||||||
(let [(amount (string->number (get-word file)))
|
(let [(amount (string->number (get-word file)))
|
||||||
(move (get-word file))]
|
(move (get-word file))]
|
||||||
@@ -39,5 +42,4 @@
|
|||||||
(else
|
(else
|
||||||
(display "part 2: ")
|
(display "part 2: ")
|
||||||
(display (* x y))
|
(display (* x y))
|
||||||
(newline)
|
(newline)))))))
|
||||||
(close-port file))))))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user