Is it possible to compose for example:
(defn- multiple-of-three? [n] (zero? (mod n 3))
(defn- multiple-of-five? [n] (zero? (mod n 5))
into:
multiple-of-three-or-five?
so I can use it for filtering:
(defn sum-of-multiples [n]
(->> (range 1 n)
(filter multiple-of-three-or-five?)
(reduce +)))
Also I don't want to define it like this:
(defn- multiple-of-three-or-five? [n]
(or (multiple-of-three? n)
(multiple-of-five? n)))
For example with Javascript module Ramda it would be achieved as: http://ramdajs.com/docs/#either
const multipleOfThreeOrFive = R.either(multipleOfThree, multipleOfFive)
or
and you can combine the expressions from your two existing into one in the newmultiple-of-three-or-five?
=(or (zero? (mod n 3)) (zero? (mod n 5)))
which will eliminate another 1-2 function calls.