Created
September 27, 2017 16:40
-
-
Save rockBreaker/2349912a814937cf600ffee0f1e749c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn parse-number | |
"Reads a number from a string. Returns nil if not a number." | |
[s] | |
(if (re-find #"^-?\d+\.?\d*$" s) | |
(read-string s))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
shamelessly stolen from https://stackoverflow.com/questions/2640169/whats-the-easiest-way-to-parse-numbers-in-clojure