-- 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 if (x == 0) (f 10) (if (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);