1

如果我处理,例如:

(define square
  (lambda (n)
    (* n n)))

例如,我使用 (square 5) 对其进行测试,如何将此结果从 Gambit Scheme 解释器传输到文本文件?

4

1 回答 1

0

One solution:

(define square
  (lambda (n)
     (* n n)))

(call-with-output-file "a-file.txt"
  (lambda ()
     (display (square 5))
     (newline)))

Another is to print directly to standard output:

(define square
  (lambda (n)
     (* n n)))

(display (square 5))
(newline)

And then use > in the shell to direct the output to a specific file.

于 2015-04-19T12:59:41.060 回答