Zygo is a Lisp interpreter written in 100% Go. Central use case: dynamically compose Go struct trees in a zygo script, then invoke compiled Go functions on those trees. Makes Go reflection easy.
(defn multArrayLoop [a b res i]
(cond (== i (len a)) res
(begin
(aset res i (* (aget a i) (aget b i)))
(multArrayLoop a b res (+ i 1)))))
(defn multArray [a b]
(multArrayLoop a b (makeArray (len a)) 0))
(defn randomArray [arr i]
(cond (== i (len arr))
arr
(begin
(aset arr i (random))
(randomArray arr (+ i 1)))))
(defn doInLoop [func times]
(cond (== times 0) %()
(begin
(func)
(doInLoop func (- times 1)))))
(timeit (fn [] (let [a (randomArray (makeArray 1000) 0)
b (randomArray (makeArray 1000) 0)]
(doInLoop (fn [] (multArray a b)) 1000))))
but it still has a prblem. I get this:
error in func:-1: Error calling 'timeit': Error calling 'func': missing arguments. use: (func funcName [inputs:type ...] [returns:type ...])
in doInLoop:11
in __anon266:15
in timeit:-1
in __main:25
I was trying to run this benchmark code https://github.com/glycerine/zygomys/blob/master/benchmarks/array-mult.zy, but it seems to be old and outdated. I tried to fix it, like this:
but it still has a prblem. I get this:
How can this be fixed?