File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ macro currently expands into extend call
277277* init-proxy
278278* DONE instance?
279279does what?
280- * int
280+ * DONE int
281281* int-array
282282* DONE integer?
283283* DONE interleave
@@ -314,7 +314,7 @@ does what?
314314* load-string
315315* loaded-libs
316316* locking
317- * TODO long
317+ * DONE long
318318* TODO long-array
319319* TODO longs
320320* DONE loop
Original file line number Diff line number Diff line change @@ -943,6 +943,16 @@ reduces them without incurring seq initialization"
943943 (Math/floor q)
944944 (Math/ceil q)))
945945
946+ (defn int
947+ " Coerce to int by stripping decimal places."
948+ [x]
949+ (fix x))
950+
951+ (defn long
952+ " Coerce to long by stripping decimal places. Identical to `int'."
953+ [x]
954+ (fix x))
955+
946956(defn mod
947957 " Modulus of num and div. Truncates toward negative infinity."
948958 [n d]
Original file line number Diff line number Diff line change 160160 (assert (= [[1 1 ] [1 2 ] [1 3 ] [2 1 ] [2 2 ] [2 3 ]]
161161 (map #(% ) (for [i [1 2 ] j [1 2 3 ]] (fn [] [i j])))))
162162
163+ (assert (= 42 (int 42.5 )))
164+ (assert (integer? (int 42.5 )))
165+
166+ (assert (= 42 (long 42.5 )))
167+ (assert (integer? (long 42.5 )))
168+
169+ (assert (= -1 (int -1.5 )))
170+ (assert (= -9 (long -9.8 )))
171+
163172 (assert (= 2 (:b {:a 1 :b 2 })))
164173 (assert (= 2 ('b '{:a 1 b 2 })))
165174 (assert (= 2 ({:a 1 :b 2 } :b )))
You can’t perform that action at this time.
0 commit comments