async on any function (no more colored function)(import std.List)
(let data [very important data here])
# the function we'll call using async
(let sum (fun (a b src) {
(mut acc 0)
(while (< a b) {
(set acc (+ acc (@ src a)))
(set a (+ 1 a))})
acc }))
# a set of calls to `sum` to compute data asynchronously
(let workers [
(async sum 0 (/ size 4) data)
(async sum (/ size 4) (/ size 2) data)
(async sum (/ size 2) (- size (/ size 4)) data)
(async sum (- size (/ size 4)) size data)])
# awaiting on all of our workers and summing it up!
(let result (list:sum (list:map workers (fun (w) (await w)))))
CompilationError: Unbound variable error "fib" (did you mean "fibo"?)
In file fibonacci.ark
On line 7:12, got `(Symbol) fib'
4 | n
5 | (+ (fibo (- n 1)) (fibo (- n 2))))))
6 | (while continue {
7 | (print (fib 28))
| ^^^
8 | (if (= (random 1 10) 1)
9 | (set continue false))You will want to learn the language first: Learning ArkScript.