[Scheme]循环读入并计算数字之和
程序员文章站
2024-01-09 16:52:58
...
一段guile脚本文件,循环读入并计算从stdin输入的两个数之和。
#!/usr/local/bin/guile -s !# (define (main) (let ((a (read (current-input-port))) (b (read (current-input-port)))) (if (not (eof-object? a)) (begin (write (+ a b) (current-output-port)) (write-char #\newline (current-output-port)) (main))))) (main)