2 ms·
We can use the technique first described here https://github.com/glenjamin/node-fib https://github.com/glenjamin/node-fib by using Fibur.pass. def fib(n)
by wycats 15y ago
We can use the technique first described here https://github.com/glenjamin/node-fib https://github.com/glenjamin/node-fib by using Fibur.pass.
def fib(n)
Fibur.pass
return n if (0..1).include? n
fib(n-1) + fib(n-2) if n > 1
end
Now, if you wrap this in Fibur.new, you will get parallel operation!
- raggi 15y agoBro, you get parallel operation anyway, that Fibur.pass just added scheduler overhead. The whole point of Fibur is you don't need to use #pass!!!