[英]How to use continue in Clojure
我正在嘗試在Clojure中實現這段Python代碼:
# Make sure the probability exceeds threshold*next best
for cat in probs:
if cat==best: continue
if probs[cat]*self.getthreshold(best)>probs[best]: return default
return best
如何在Clojure中繼續使用。 我應該使用什么機制?
(->> probs
(remove (partial = best))
(reduce (fn [best prob] strong text
(if (> (* prob (get-threshold best)) best)
(reduced default)
best)) best))
最有可能的是充滿錯誤,但是要點是刪除概率等於最佳的錯誤,然后將其余錯誤減少為default
。
從減少提前返回的技巧是使用reduced
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.