mirror of
https://github.com/anoma/juvix.git
synced 2024-11-30 14:13:27 +03:00
b8cd84170b
This PR updates the juvix-stdlib to the current main commit which includes: * https://github.com/anoma/juvix-stdlib/issues/59 * https://github.com/anoma/juvix-stdlib/issues/101 All the Juvix test suite files and examples in this repo have been updated to be compatible with the new stdlib.
23 lines
423 B
Plaintext
23 lines
423 B
Plaintext
-- tail recursion
|
|
module test009;
|
|
|
|
import Stdlib.Prelude open;
|
|
|
|
sum' (acc : Nat) : Nat → Nat
|
|
| zero := acc
|
|
| (suc x) := sum' (suc x + acc) x;
|
|
|
|
sum : Nat → Nat := sum' 0;
|
|
|
|
fact' (acc : Nat) : Nat → Nat
|
|
| zero := acc
|
|
| (suc x) := fact' (acc * suc x) x;
|
|
|
|
fact : Nat → Nat := fact' 1;
|
|
|
|
main : IO :=
|
|
printNatLn (sum 10000)
|
|
>>> printNatLn (fact 5)
|
|
>>> printNatLn (fact 10)
|
|
>>> printNatLn (fact 12);
|