为什么调用此函数不会打印任何内容?
(defn test-go-loop []
(go (for [a (cycle [:a :b :c])]
(do (println a) (<! (timeout 1000))))))
Run Code Online (Sandbox Code Playgroud)
for懒惰评估,你的代码中没有任何东西要求结果for.试试doseq:
(defn test-go-loop []
(go (doseq [a (cycle [:a :b :c])]
(println a)
(<! (timeout 1000)))))
Run Code Online (Sandbox Code Playgroud)