File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -278,7 +278,7 @@ macro currently expands into extend call
278278* DONE instance?
279279does what?
280280* DONE int
281- * int-array
281+ * DONE int-array
282282* DONE integer?
283283* DONE interleave
284284* intern
Original file line number Diff line number Diff line change @@ -2131,6 +2131,27 @@ reduces them without incurring seq initialization"
21312131 (recur (inc i) (next xs))))
21322132 ret))
21332133
2134+ (defn int-array
2135+ ([size-or-seq]
2136+ (cond
2137+ (number? size-or-seq) (int-array size-or-seq nil )
2138+ (seq? size-or-seq) (into-array size-or-seq)
2139+ :else (throw (js/Error. " int-array called with something other than size or ISeq" ))))
2140+ ([size init-val-or-seq]
2141+ (let [a (make-array size)]
2142+ (if (seq? init-val-or-seq)
2143+ (let [s (seq init-val-or-seq)]
2144+ (loop [i 0 s s]
2145+ (if (and s (< i size))
2146+ (do
2147+ (aset a i (first s))
2148+ (recur (inc i) (next s)))
2149+ a)))
2150+ (do
2151+ (dotimes [i size]
2152+ (aset a i init-val-or-seq))
2153+ a)))))
2154+
21342155(defn long-array
21352156 ([size-or-seq]
21362157 (cond
You can’t perform that action at this time.
0 commit comments