More useable signature for 'Array.element-count'.

This commit is contained in:
Erik Svedäng 2018-03-12 12:11:33 +01:00
parent b23d60616b
commit 0301837072
4 changed files with 7 additions and 3 deletions

View File

@ -85,7 +85,7 @@
(defn element-count [a e]
(let-do [c 0]
(for [i 0 (count a)]
(when (= e @(nth a i)) (set! c (Int.inc c))))
(when (= e (nth a i)) (set! c (Int.inc c))))
c))
(defn aupdate [a i f]

View File

@ -23,3 +23,7 @@
(defn /= [a b]
(not (= (the Char a) b)))
)
(defmodule CharRef
(defn = [a b]
(Char.= @a @b)))

View File

@ -83,7 +83,7 @@
(let [x @(Array.nth data (/ n 2)) ; else
l (- x (/ (from-int interval) 2.0))
cf (Array.index-of data x)
f (Array.element-count 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

@ -40,7 +40,7 @@
(for [i 0 len]
(let [c (Array.nth &cs i)]
(do
(if (Int.< 0 (Array.element-count &(the (Array Char) @&separators) @c))
(if (Int.< 0 (Array.element-count &(the (Array Char) @&separators) c))
(if (= 0 (String.count &word))
() ;; no word
(do (set! result (Array.push-back @&result @&word))