[Scheme]循环读入并计算数字之和
程序员文章站
2024-02-10 23:32:52
...
一段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)
上一篇: django中的ORM