Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ummm....

Following the first thing in the tutorial:

Clojure> (+3 3)

java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn

http://gyazo.com/22c613f5bb4ebda5a36d0fbc0a85b83d

What have I missed?



So just to give you some background. In any Lisp, when you evaluate a list, the first element is treated as an operator, and the remaining items are treated as arguments. Moreover, there is no distinction between graphic characters or alphabetic characters for the purposes of defining variable names. So '+' is a valid name for a variable (which is bound to the addition function), and so is '+3'. So without the space, it thinks you are trying to call the function '+3' with the argument '3'.


You need a space between the + and the first 3 (+ is the function you want to call).


Thanks. The tutorial didn't show that:

http://gyazo.com/9d330e8bdb0537f9179c34ad2924928c

And when I click the tutorial's "(+3 3)" grey box, it inserts what looks like no space between the + and 3, and lo and behold, it works (6). And when I type it in now with no space (+3 3) it works too. :/


oops - sorry - I'm totally misreading it. :/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: