(defn divisible [x y] (zero? (rem x y)))
- ((or (fn [x] (divisible x 3)) (fn [x] (divisible x 5))) 3)
- ((or (fn [x] (divisible x 3)) (fn [x] (divisible x 5))) 5)
the first expression evals to true but not the second one why?
- can some on explain whats going on here?
An expression of the form
(or foo bar)does not “glue together” two predicates into one compound predicate; it returnsfooif it is truthy, elsebar. In your code,(fn [x] (divisible x 3))is of course truthy (the only falsey values arefalseandnil), so the whole thing is equivalent toWhat you want to do is something like
In general,