#lang scheme (require scheme/port lang/error) (provide with-input-from-string with-output-to-string with-input-from-file with-output-to-file with-io-strings) ; with-io-strings : input(string) thunk -> string (define (with-io-strings input thunk) (check-arg 'with-io-strings (string? input) "string" "first" input) (check-arg 'with-io-strings (and (procedure? thunk) (procedure-arity-includes? thunk 0)) "0-parameter function" "second" thunk) (with-output-to-string (lambda () (with-input-from-string input thunk))))