Concurrency

constant DEPTH = 5; sub fib-promise($n, $depth = DEPTH) { if $n < 2 { return $n; } given ($depth) { when DEPTH { my @promises = ( fib-promise($n - 2, $depth - 1), fib-promise($n - 1, $depth - 1), ).flat; await Promise.allof(@promises); return [+] @promises>>.result; } ...