mirror of
https://github.com/richardharrington/robotwar.git
synced 2026-04-21 15:16:29 +00:00
changed str-int to use try/catch instead of a regular expression check
This commit is contained in:
@@ -46,10 +46,10 @@
|
||||
:pos (:pos first-token)})
|
||||
|
||||
(defn str->int
|
||||
"Like Integer/parseInt, but returns nil on failure"
|
||||
[s]
|
||||
(and (re-matches #"-?\d+" s)
|
||||
(Integer/parseInt s)))
|
||||
"Integer/parseInt, but returns nil on failure"
|
||||
[s-raw]
|
||||
(try (Integer/parseInt s-raw)
|
||||
(catch Exception e nil)))
|
||||
|
||||
(defn valid-word
|
||||
"Capital letters and numbers, starting with a capital letter"
|
||||
|
||||
Reference in New Issue
Block a user