Nikita Davidenko
Nikita Davidenko

Reputation: 160

java.lang.Long cannot be cast to clojure.lang.IFn I don't understend why I recive this

(def text1 "qwwqer qwasdfas")
(defn countL [text char] (reduce 0
                                 #(if (= %2 char) (+ %1 1) (+ %1 0))
                                 text)
)
(println (countL text1 "q"))

I write this code and recive this error, but I not understand why? Please explain to me.

Upvotes: 0

Views: 287

Answers (1)

Mark Mucha
Mark Mucha

Reputation: 1589

The argument order for reduce is incorrect. See https://clojuredocs.org/clojure.core/reduce

Upvotes: 3

Related Questions