-- 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 | else := 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 : IO := printNatLn (f 100 500) >>> -- 600 printNatLn (f 5 0) >>> -- 25 printNatLn (f 5 5) >>> -- 30 printNatLn (h 10) >>> -- 45 printNatLn (g 10 h) >>> -- 55 printNatLn (g 3 (f 10));