Mar*_*ins 3 lisp python clisp common-lisp
我正在努力将一些现有的Python代码转换为CLisp,就像练习一样......
程序读取数字列表并从列表中创建平均值,最小值,最大值和标准偏差.我有基于文件的功能:
(defun get-file (filename)
(with-open-file (stream filename)
(loop for line = (read-line stream nil)
while line
collect (parse-float line))))
Run Code Online (Sandbox Code Playgroud)
当我将其称为时,这可以工作
(get-file "/tmp/my.filename")
Run Code Online (Sandbox Code Playgroud)
...但我想让程序读取标准输入,我尝试了各种各样的事情,没有运气.
有什么建议?
只是单独关注:
(defun get-stream (stream)
(loop for line = (read-line stream nil)
while line
collect (parse-float line)))
(defun get-file (filename)
(with-open-file (stream filename)
(get-stream stream)))
Run Code Online (Sandbox Code Playgroud)
然后你可以get-file像你已经做的那样使用,并且(get-stream *standard-input*).
| 归档时间: |
|
| 查看次数: |
131 次 |
| 最近记录: |