clojure - Understanding recur -


trying out snippet of code , doesn't seem working quite right..

(defn- multiple_of?   [div num]   (= (mod num div) 0))  (defn sum_of_multiples_from    ([start] (sum_of_multiples_from start 0))   ([start total]    (if (<= start 0)      total      (recur (dec start) (or (multiple_of? 3 start) (multiple_of? 5 start)                             (+ total start) start))))) 

i receive following error:

java.lang.boolean cannot cast java.lang.number

i guessing has with:

(recur (dec start) (or (multiple_of? 3 start) (multiple_of? 5 start)                             (+ total start)                             start))))) 

but i'm not sure why, i'm new clojure, i'm trying grasp of recur.

your or call returns boolean ((multiple_of? 3 start)) start multiple of 3.

in clojure, or returns 1 of arguments -- either first truish 1 if 1 exists, or last falsish 1 otherwise.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -