RosettaCodeData/Task/Determine-if-a-string-is-numeric/Clojure/determine-if-a-string-is-numeric-1.clj

8 lines
252 B
Clojure
Raw Permalink Normal View History

2013-04-10 12:38:42 -07:00
(defn numeric? [s]
(if-let [s (seq s)]
(let [s (if (= (first s) \-) (next s) s)
s (drop-while #(Character/isDigit %) s)
s (if (= (first s) \.) (next s) s)
s (drop-while #(Character/isDigit %) s)]
(empty? s))))