Merge pull request #480 from agentultra/digit-char
Add integer-char? to core
This commit is contained in:
commit
20d27b23e9
@ -177,6 +177,13 @@
|
|||||||
"Return True if x in an integer"
|
"Return True if x in an integer"
|
||||||
(isinstance x (, int long-type)))
|
(isinstance x (, int long-type)))
|
||||||
|
|
||||||
|
(defn integer-char? [x]
|
||||||
|
"Return True if char `x` parses as an integer"
|
||||||
|
(try
|
||||||
|
(integer? (int x))
|
||||||
|
(catch [e ValueError] False)
|
||||||
|
(catch [e TypeError] False)))
|
||||||
|
|
||||||
(defn iterable? [x]
|
(defn iterable? [x]
|
||||||
"Return true if x is iterable"
|
"Return true if x is iterable"
|
||||||
(try (do (iter x) true)
|
(try (do (iter x) true)
|
||||||
@ -314,9 +321,11 @@
|
|||||||
(_numeric_check n)
|
(_numeric_check n)
|
||||||
(= n 0))
|
(= n 0))
|
||||||
|
|
||||||
(def *exports* '[calling-module-name coll? cycle dec distinct disassemble
|
(def *exports* '[calling-module-name coll? cycle dec distinct
|
||||||
drop drop-while empty? even? first filter flatten float?
|
disassemble drop drop-while empty? even? first filter
|
||||||
gensym identity inc instance? integer integer? iterable?
|
flatten float? gensym identity inc instance? integer
|
||||||
iterate iterator? macroexpand macroexpand-1 neg? nil?
|
integer? integer-char? iterable? iterate iterator?
|
||||||
none? nth numeric? odd? pos? remove repeat repeatedly
|
macroexpand macroexpand-1 neg? nil? none? nth
|
||||||
rest second string string? take take-nth take-while zero?])
|
numeric? odd? pos? remove repeat repeatedly rest
|
||||||
|
second string string? take take-nth take-while
|
||||||
|
zero?])
|
||||||
|
@ -223,6 +223,14 @@
|
|||||||
(assert-false (integer? None))
|
(assert-false (integer? None))
|
||||||
(assert-false (integer? "foo")))
|
(assert-false (integer? "foo")))
|
||||||
|
|
||||||
|
(defn test-integer-char? []
|
||||||
|
"NATIVE: testing the integer-char? function"
|
||||||
|
(assert-true (integer-char? "1"))
|
||||||
|
(assert-true (integer-char? "-1"))
|
||||||
|
(assert-true (integer-char? (str (integer 300))))
|
||||||
|
(assert-false (integer-char? "foo"))
|
||||||
|
(assert-false (integer-char? None)))
|
||||||
|
|
||||||
(defn test-iterable []
|
(defn test-iterable []
|
||||||
"NATIVE: testing iterable? function"
|
"NATIVE: testing iterable? function"
|
||||||
;; should work for a string
|
;; should work for a string
|
||||||
|
Loading…
Reference in New Issue
Block a user