mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00

Since 0.101.0 we will finally catch more illegal `def` signatures. As the grammar for input/output types is rather restricted, this would error otherwise
11 lines
287 B
Text
11 lines
287 B
Text
|
|
# Simple countdown counter from some number n to 0. Returns 0 at end
|
|
# Designed to be used with the tramp module to avoid stack overflows via the
|
|
# use of the Trampoline method.
|
|
def countdown [n: int]: nothing -> int {
|
|
if $n == 0 {
|
|
0
|
|
} else {
|
|
{|| countdown ($n - 1) }
|
|
}
|
|
}
|