I've been trying to figure this one our for a while now.
(defn is-decimal [astr]
(if (. astr (indexOf (int \.)))
(Double/parseDouble astr)
(Integer/parseInt astr)))
That is the function I wrote. is-decimal is either passed something like this "2.5" or "5" or something of the sort, but it always uses 'if's second argument never its third. I tested (. astr (indexOf (int .))) out in the REPL, and it seems to be working fine, it returns -1 when it fails and 1 when it doesn't. I believe that might be the problem. -1 doesn't mean false in Clojure. Can anyone think of a way to fix this?
Thanks in advance.
EDIT: Thanks for the help guys. Right after I wrote this I had an idea. I wrote a predicate function that checks for 1 and -1. Just what I needed. I shouldn't code directly after waking up :\