Skip to content

Commit

Permalink
crook
Browse files Browse the repository at this point in the history
  • Loading branch information
dvanhorn committed Nov 25, 2024
1 parent 8b6393c commit 5cb072e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions iniquity-plus/interp-io.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
;; Interpret p with given string as input,
;; return value and collected output as string
(define (interp/io p input)
(parameterize ((current-output-port (open-output-string))
(current-input-port (open-input-string input)))
(cons (interp p)
(get-output-string (current-output-port)))))
(define result (box #f))
(define output
(with-input-from-string input
(λ ()
(with-output-to-string
(λ ()
(set-box! result (interp p)))))))
(cons (unbox result) output))

12 changes: 8 additions & 4 deletions knock-plus/interp-io.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
;; Interpret p with given string as input,
;; return value and collected output as string
(define (interp/io p input)
(parameterize ((current-output-port (open-output-string))
(current-input-port (open-input-string input)))
(cons (interp p)
(get-output-string (current-output-port)))))
(define result (box #f))
(define output
(with-input-from-string input
(λ ()
(with-output-to-string
(λ ()
(set-box! result (interp p)))))))
(cons (unbox result) output))

0 comments on commit 5cb072e

Please sign in to comment.