|
8 | 8 |
|
9 | 9 | (ns cljs.core |
10 | 10 | (:require goog.math.Long |
| 11 | + goog.math.Integer |
11 | 12 | [goog.string :as gstring] |
12 | 13 | [goog.object :as gobject] |
13 | 14 | [goog.array :as garray]) |
@@ -2124,25 +2125,57 @@ reduces them without incurring seq initialization" |
2124 | 2125 | (not (identical? n js/Infinity)) |
2125 | 2126 | (== (js/parseFloat n) (js/parseInt n 10)))) |
2126 | 2127 |
|
2127 | | -(defn ^boolean long? |
2128 | | - "Return true if x is an instance of goog.math.Long" |
2129 | | - [x] (instance? goog.math.Long x)) |
2130 | | - |
2131 | | -(defn ^boolean pos-long? |
2132 | | - "Return true if x is a positive Long" |
2133 | | - [x] (and (instance? goog.math.Long x) |
2134 | | - (not (.isNegative x)) |
2135 | | - (not (.isZero x)))) |
2136 | | - |
2137 | | -(defn ^boolean neg-long? |
2138 | | - "Return true if x is a negative Long" |
2139 | | - [x] (and (instance? goog.math.Long x) |
2140 | | - (.isNegative x))) |
2141 | | - |
2142 | | -(defn ^boolean nat-long? |
2143 | | - "Return true if x is a non-negative Long" |
2144 | | - [x] (and (instance? goog.math.Long x) |
2145 | | - (or (not (.isNegative x)) (.isZero x)))) |
| 2128 | +(defn ^boolean int? |
| 2129 | + "Return true if x is an integer" |
| 2130 | + [x] |
| 2131 | + (or (integer? x) |
| 2132 | + (instance? goog.math.Integer x) |
| 2133 | + (instance? goog.math.Long x))) |
| 2134 | + |
| 2135 | +(defn ^boolean pos-int? |
| 2136 | + "Return true if x is a positive integer" |
| 2137 | + [x] |
| 2138 | + (cond |
| 2139 | + (integer? x) (pos? x) |
| 2140 | + |
| 2141 | + (instance? goog.math.Integer x) |
| 2142 | + (and (not (.isNegative x)) |
| 2143 | + (not (.isZero x))) |
| 2144 | + |
| 2145 | + (instance? goog.math.Long x) |
| 2146 | + (and (not (.isNegative x)) |
| 2147 | + (not (.isZero x))) |
| 2148 | + |
| 2149 | + :else false)) |
| 2150 | + |
| 2151 | +(defn ^boolean neg-int? |
| 2152 | + "Return true if x is a negative integer" |
| 2153 | + [x] |
| 2154 | + (cond |
| 2155 | + (integer? x) (neg? x) |
| 2156 | + |
| 2157 | + (instance? goog.math.Integer x) |
| 2158 | + (.isNegative x) |
| 2159 | + |
| 2160 | + (instance? goog.math.Long x) |
| 2161 | + (.isNegative x) |
| 2162 | + |
| 2163 | + :else false)) |
| 2164 | + |
| 2165 | +(defn ^boolean nat-int? |
| 2166 | + "Return true if x is a non-negative integer" |
| 2167 | + [x] |
| 2168 | + (cond |
| 2169 | + (integer? x) |
| 2170 | + (or (not (neg? x)) (zero? x)) |
| 2171 | + |
| 2172 | + (instance? goog.math.Integer x) |
| 2173 | + (or (not (.isNegative x)) (.isZero x)) |
| 2174 | + |
| 2175 | + (instance? goog.math.Long x) |
| 2176 | + (or (not (.isNegative x)) (.isZero x)) |
| 2177 | + |
| 2178 | + :else false)) |
2146 | 2179 |
|
2147 | 2180 | (defn ^boolean contains? |
2148 | 2181 | "Returns true if key is present in the given collection, otherwise |
|
0 commit comments