1
1
mirror of https://github.com/anoma/juvix.git synced 2024-11-30 05:42:26 +03:00
juvix/tests/Rust/Compilation/positive/test015.juvix
2024-07-02 10:03:06 +02:00

44 lines
585 B
Plaintext

-- local functions with free variables
module test015;
import Stdlib.Prelude open;
terminating
f : Nat → Nat → Nat
| x :=
let
g (y : Nat) : Nat := x + y;
in ite
(x == 0)
(f 10)
(ite (x < 10) λ {y := g (f (sub x 1) y)} g);
g (x : Nat) (h : Nat → Nat) : Nat := x + h x;
terminating
h : Nat → Nat
| zero := 0
| (suc x) := g x h;
main : Nat :=
f 100 500
+ -- 600
f
5
0
+ -- 25
f
5
5
+ -- 30
h
10
+ -- 45
g
10
h
+ -- 55
g
3
(f 10);