1
1
mirror of https://github.com/anoma/juvix.git synced 2025-01-07 08:08:44 +03:00
juvix/tests/Compilation/positive/test030.juvix
Łukasz Czajka 2baad15a41 Remove old function syntax (#2305)
* Enables new function syntax in local let-declarations
* Closes #2251
2023-08-24 16:24:47 +02:00

29 lines
697 B
Plaintext

-- Ackermann function (higher-order definition)
module test030;
import Stdlib.Prelude open hiding {iterate};
iterate : {A : Type} → (A → A) → Nat → A → A
-- clauses with differing number of patterns not yet supported
-- iterate f zero x := x;
| f zero := id
| f (suc n) := f ∘ iterate f n;
plus : Nat → Nat → Nat := iterate suc;
mult : Nat → Nat → Nat
| m n := iterate (plus n) m 0;
exp : Nat → Nat → Nat
| m n := iterate (mult m) n 1;
ackermann : Nat → Nat → Nat
| m := iterate λ {f n := iterate f (suc n) 1} m suc;
main : IO :=
printNatLn (plus 3 7)
>> printNatLn (mult 3 7)
>> printNatLn (exp 3 7)
>> printNatLn (ackermann 3 7);