1
1
mirror of https://github.com/anoma/juvix.git synced 2025-01-07 08:08:44 +03:00
juvix/tests/Compilation/positive/test023.juvix
Łukasz Czajka 60a191b786
Numeric, ordering and equality traits (#2433)
* Adapts to https://github.com/anoma/juvix-stdlib/pull/86
* Adds a pass in `toEvalTransformations` to automatically inline all
record projection functions, regardless of the optimization level. This
is necessary to ensure that arithmetic operations and comparisons on
`Nat` or `Int` are always represented directly with the corresponding
built-in Core functions. This is generally highly desirable and required
for the Geb target.
* Adds the `inline: always` pragma which indicates that a function
should always be inlined during the mandatory inlining phase, regardless
of optimization level.
2023-10-09 18:25:01 +02:00

24 lines
365 B
Plaintext

-- mutual recursion
module test023;
import Stdlib.Prelude open;
terminating
f : Nat → Nat
| x := if (x < 1) 1 (2 * x + g (sub x 1));
terminating
g : Nat → Nat
| x := if (x < 1) 1 (x + h (sub x 1));
terminating
h : Nat → Nat
| x := if (x < 1) 1 (x * f (sub x 1));
main : IO :=
printNatLn (f 5)
>> printNatLn (f 10)
>> printNatLn (f 20);