Outside of the function, the code works as expected, but in the following code it returns exception on a test site [Exception in thread "main" java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn]
How can I keep the function structure & get the results to print?
(defn sumTerm [hi lo]
(if (< hi lo)
(0)
(let [
terms (quot hi lo)
tb (+ terms 1)
]
(quot (* lo terms tb) 2)
)
))
let [
ln 27
a (sumTerm ln 4)
b (sumTerm ln 7)
abc (- (+ a b) (sumTerm ln 28))
]
(println " abc= "(str abc))
It cannot work as expected unless you never hit the (< hi lo)
's "then" branch, because you're trying to call 0
as a function by wrapping it in parentheses.
Try replacing (0)
with just 0
.