I started doing Project Euler with Clojure, as the first blow in learning Clojure. I solved the first task:
Find the sum of all multiples of 3 or 5 below 1000.
I previously solved it in Python:
sum(i for i in xrange(1000) if i%3==0 or i%5==0)
This is my first attempt at Clojure:
(reduce + (filter (fn [x] (or (= 0 (mod x 3)) (= 0 (mod x 5)))) (range 1000)))
I am really surprised at how well he is brought to the end, but I am sure that this is due to my style and ignorance of Clojure idioms.
What would an idiomatic version of this Clojure code look like?
gumuz
source share