【发布时间】:2010-11-06 21:07:15
【问题描述】:
我有一个函数,它从被调用的输入流中读取一个标记(get-next-indicator 流指示符)并返回它。我正在尝试使用它来构建地图。
但是,当我运行它时,它会锁定。如果我删除 get-next-indicator 函数之一,它确实有效。 这两个函数是否尝试同时读取流是这样的。是什么原因造成的?
(defn decode-map [ stream ]
(loop [result {}]
(let [c (char (.read stream))]
(if (= c \e)
result
(recur (assoc result (get-next-indicator stream (int c))
(get-next-indicator stream (int c)) ))))))
【问题讨论】:
-
“锁定”是什么意思?有错误信息吗?
-
没有错误信息 repl loop just locks 注意被打印。如果我用say“e”替换对get-next-indicator的第二次调用,它会按预期生成地图,但是当它像我的sn-p一样被调用时。什么都没发生。没有错误没有例外。
-
get-next-indicator 有副作用吗?也发布代码。
标签: function recursion clojure stream