Introduction
Resursion is an important technique in programming, especially in functional programming.
Simple examples:
fact :: Integer -> Integer
fact 0 = 1
fact n = n * fact (n - 1)
> fact 10
3628800
> fact 5
120
fib :: Integer -> Integer
fib 0 = 1
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)
> fib 10
89
> fib 5
8
当前内容版权归 hamler-lang 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 hamler-lang .