What's wrong with my definition of sqrt?

user=> (defn sqrt [x] (. System.Math Sqrt x))
#'user/sqrt
user=> (sqrt 4)
System.InvalidCastException: Specified cast is not valid.
   at lambda_method(Closure , Object )
   at AFunction_impl.invoke(Object )
   at lambda_method(Closure )
   at AFunction_impl.invoke()
   at REPLCall(Closure )

It works from REPL:
user=> (. System.Math Sqrt 4)
2

Notice that
user=> (sqrt 4.0)
2

works as expected.

- Dmitry

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to