Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What's wrong with this Clojure function?

I’am new to clojure and i wrote this func:

 (def fact (fn [n] (
   (apply * (drop 1 (range n))))))

When calling it i get the error:

ClassCastException class java.lang.Long cannot be cast to class clojure.lang.IFn (java.lang.Long is in module java.base of loader ‘bootstrap’; clojure.lang.IFn is in unnamed module of loader ‘app’) my-stuff.core/fact (form-init3352210926102455316.clj:18)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Why?

>Solution :

You’ve got an extra parenthesis around apply:

(def fact (fn [n]
              (apply * (drop 1 (range n)))))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading