Files
dotfiles/dot_config/nushell/nu_scripts/benchmarks/fibonacci-recursive.nu
Cian Hughes 896af887ca Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows)
and improves grepability with neovim/telescope
2024-11-07 13:52:17 +00:00

18 lines
344 B
Nu

#!/usr/bin/env nu
# This is a much less efficient, recursive version of fibonacci that can be used to test our
# command call performance.
use std bench
def fib [n: int] {
match $n {
0 => 0,
1 => 1,
$n => { (fib ($n - 1)) + (fib ($n - 2)) },
}
}
def main [] {
print (bench { 0..20 | each { |n| fib $n } } | reject times)
}