Change signature of Array.index-of to take a ref instead.

This commit is contained in:
Erik Svedäng 2018-12-15 23:18:34 +01:00
parent bf24288859
commit 2900746f14
4 changed files with 4 additions and 4 deletions

View File

@ -125,7 +125,7 @@
(defn index-of [a e]
(let-do [idx -1]
(for [i 0 (length a)]
(when (= (nth a i) &e)
(when (= (nth a i) e)
(do
(set! idx i)
(break))))

View File

@ -82,7 +82,7 @@
(= n 1) @(Array.nth data 0)
(let [x @(Array.nth data (/ n 2)) ; else
l (- x (/ (from-int interval) 2.0))
cf (Array.index-of data x)
cf (Array.index-of data &x)
f (Array.element-count data &x)]
(+ l (/ (* (from-int interval) (- (/ (from-int n) 2.0) (from-int cf)))
(from-int f)))))))

View File

@ -564,7 +564,7 @@
defn
</div>
<p class="sig">
(λ [(Ref (Array a)), a] Int)
(λ [(Ref (Array a)), &amp;a] Int)
</p>
<pre class="args">
(index-of a e)

View File

@ -247,7 +247,7 @@
(defn array-index-of []
(let [xs [@"a" @"b" @"c" @"d" @"e"]]
(assert (= 2 (Array.index-of &xs @"c")))))
(assert (= 2 (Array.index-of &xs "c")))))
(defn array-element-count []
(let [xs [@"a" @"b" @"a" @"a" @"b"]]