mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
Change signature of Array.index-of to take a ref instead.
This commit is contained in:
parent
bf24288859
commit
2900746f14
@ -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))))
|
||||
|
@ -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)))))))
|
||||
|
@ -564,7 +564,7 @@
|
||||
defn
|
||||
</div>
|
||||
<p class="sig">
|
||||
(λ [(Ref (Array a)), a] Int)
|
||||
(λ [(Ref (Array a)), &a] Int)
|
||||
</p>
|
||||
<pre class="args">
|
||||
(index-of a e)
|
||||
|
@ -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"]]
|
||||
|
Loading…
Reference in New Issue
Block a user