How to evaluate a sequence of impure functions in Clojure?

前端 未结 4 2067
没有蜡笔的小新
没有蜡笔的小新 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:55

    user> (let [fs [#(println "1") #(println "2") #(println "3")]]
             (doseq [f fs] (f)))
    1
    2
    3
    nil
    

提交回复
热议问题