5 ms·
I tried the live repl and input the fibonacci example: > (fn fib [n] (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2))))) which seemed to take, but th
by eggy 8y ago
I tried the live repl and input the fibonacci example:
> (fn fib [n]
(if (< n 2)
n
(+ (fib (- n 1)) (fib (- n 2)))))
which seemed to take, but then upon trying
(print (fib 10))
it spit out the following:
[string "return print(fib(10))"]:1: attempt to call a nil value (global 'fib')
Do I need to initialize fib before in the repl?
- veli_joza 8y agoIt works if you run both expressions from file. There's a tutorial page that explains why this doesn't work in REPL. See "Locals are per-chunk" here: https://github.com/bakpakin/Fennel/blob/master/tutorial.md#gotchas https://github.com/bakpakin/Fennel/blob/master/tutorial.md#g...
- eggy 8y agoThanks, that makes sense. I will also try making it a global value assuming global works in the online REPL.