这是Clojure勇敢而真实的例子:
(time
(let [butter-promise (promise)]
(doseq [butter [yak-butter-international butter-than-nothing baby-got-yak]]
(future (if-let [satisfactory-butter (satisfactory? (mock-api-call butter))]
(deliver butter-promise satisfactory-butter))))
(println "And the winner is:" @butter-promise)))
如果黄油产品都不符合我们的标准怎么办?
最佳答案
(let [butter-promise (promise)]
;; ...
(if-let [winner (deref butter-promise 10000 nil)]
(println "And the winner is:" winner)
(println "Butter timed out."))