How to evaluate a sequence of impure functions in Clojure?

前端 未结 4 2165
没有蜡笔的小新
没有蜡笔的小新 2021-01-17 13:09

How can I evaluate a list of (impure) functions in Clojure? For instance:

[#(println \"1\") #(println \"2\") #(println \"3\")]

The expected

4条回答
  •  遥遥无期
    2021-01-17 13:47

    (apply pcalls [#(println "1") #(println "2") #(println "3")]) does just that. Just be wary of pcalls' parallelism (therefore lack of sequentiality) and lazyness.

提交回复
热议问题