mirror of
https://github.com/Cian-H/dotfiles.git
synced 2026-01-23 10:59:04 +00:00
Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows) and improves grepability with neovim/telescope
This commit is contained in:
9
dot_config/nushell/nu_scripts/modules/recursion/fact.nu
Normal file
9
dot_config/nushell/nu_scripts/modules/recursion/fact.nu
Normal file
@@ -0,0 +1,9 @@
|
||||
# Compute the factorial of a number
|
||||
# This version just returns either the value or a thunk.
|
||||
# Meant to be used in a trampoline
|
||||
# But still uses APS
|
||||
def fact [n: int, acc=1] -> int {
|
||||
if $n <= 1 { return $acc } else {
|
||||
{|| fact ($n - 1) ($n * $acc) } # The thunk being returned to the trampoline
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user