Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,7 @@
|
|||
(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))))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(numeric? [\1 \2 \3]) ;; yields logical true
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
(require '[clojure.edn :as edn])
|
||||
(import [java.io PushbackReader StringReader])
|
||||
|
||||
(defn number-string? [s]
|
||||
(boolean
|
||||
(when (and (string? s) (re-matches #"^[+-]?\d.*" s))
|
||||
(let [reader (PushbackReader. (StringReader. s))
|
||||
num (try (edn/read reader) (catch Exception _ nil))]
|
||||
(when num
|
||||
; Check that the string has nothing after the number
|
||||
(= -1 (.read reader)))))))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
user=> (number-string? "2r101010")
|
||||
true
|
||||
user=> (number-string? "22/7")
|
||||
true
|
||||
Loading…
Add table
Add a link
Reference in a new issue