Skip to content

Commit 224e140

Browse files
committed
clarify integer predicate docstrings, formatting
1 parent 647736a commit 224e140

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,22 +2126,23 @@ reduces them without incurring seq initialization"
21262126
(or (fn? f) (satisfies? IFn f)))
21272127

21282128
(defn ^boolean integer?
2129-
"Returns true if n is an integer."
2129+
"Returns true if n is a JavaScript number with no decimal part."
21302130
[n]
21312131
(and (number? n)
21322132
(not ^boolean (js/isNaN n))
21332133
(not (identical? n js/Infinity))
21342134
(== (js/parseFloat n) (js/parseInt n 10))))
21352135

21362136
(defn ^boolean int?
2137-
"Return true if x is an integer"
2137+
"Return true if x satisfies integer? or is an instance of goog.math.Integer
2138+
or goog.math.Long."
21382139
[x]
21392140
(or (integer? x)
21402141
(instance? goog.math.Integer x)
21412142
(instance? goog.math.Long x)))
21422143

21432144
(defn ^boolean pos-int?
2144-
"Return true if x is a positive integer"
2145+
"Return true if x satisfies int? and is positive."
21452146
[x]
21462147
(cond
21472148
(integer? x) (pos? x)
@@ -2157,7 +2158,7 @@ reduces them without incurring seq initialization"
21572158
:else false))
21582159

21592160
(defn ^boolean neg-int?
2160-
"Return true if x is a negative integer"
2161+
"Return true if x satisfies int? and is positive."
21612162
[x]
21622163
(cond
21632164
(integer? x) (neg? x)
@@ -2171,7 +2172,7 @@ reduces them without incurring seq initialization"
21712172
:else false))
21722173

21732174
(defn ^boolean nat-int?
2174-
"Return true if x is a non-negative integer"
2175+
"Return true if x satisfies int? and is a natural integer value."
21752176
[x]
21762177
(cond
21772178
(integer? x)

src/test/cljs/cljs/predicates_test.cljs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@
3939
posi (Integer.fromNumber posint)
4040
negi (Integer.fromNumber negint)]
4141
[[identity neg? pos? integer? int? neg-int? pos-int? nat-int?]
42-
[0 false false true true false false true ]
43-
[1 false true true true false true true ]
44-
[-1 true false true true true false false ]
45-
[1.0 false true true true false true true ]
46-
[-1.0 true false true true true false false ]
47-
[posint false true true true false true true ]
48-
[negint true false true true true false false ]
49-
[natl false false false true false false true ]
50-
[posl false true false true false true true ]
51-
[negl true false false true true false false ]
52-
[nati false false false true false false true ]
53-
[posi false true false true false true true ]
54-
[negi true false false true true false false ]]))
42+
[0 false false true true false false true ]
43+
[1 false true true true false true true ]
44+
[-1 true false true true true false false ]
45+
[1.0 false true true true false true true ]
46+
[-1.0 true false true true true false false ]
47+
[posint false true true true false true true ]
48+
[negint true false true true true false false ]
49+
[natl false false false true false false true ]
50+
[posl false true false true false true true ]
51+
[negl true false false true true false false ]
52+
[nati false false false true false false true ]
53+
[posi false true false true false true true ]
54+
[negi true false false true true false false ]]))
5555

5656
(deftest test-int-preds
5757
(let [[preds & rows] int-val-table]

0 commit comments

Comments
 (0)