2 ms·
(defn safe-average [a b c d] (let [total 0 count 0] (when a (add! total a) (inc! count)) (when b (add! total b) (inc! count)) (when c (add
by kazinator 11y ago
(defn safe-average [a b c d]
(let [total 0 count 0]
(when a (add! total a) (inc! count))
(when b (add! total b) (inc! count))
(when c (add! total c) (inc! count))
(when d (add! total d) (inc! count))
(/ total count)))
Doesn't appear so safe against division by zero!
- whitegrape 11y agoThe demo and step by step blog is great but there is some really bad code in it... Is it idiomatic Wisp to keep the surface-level syntax of Clojure but none of the important bits like immutability and abstractions?