mirror of
https://github.com/anoma/juvix.git
synced 2025-01-07 16:22:14 +03:00
186f4f66ef
Adds Juvix tests for the compilation pipeline - these are converted from the JuvixCore tests (those that make sense). Currently, only the translation from Juvix to JuvixCore is checked for the tests that can be type-checked. Ultimately, the entire compilation pipeline down to native code / WebAssembly should be checked on these tests. Closes #1689
21 lines
367 B
Plaintext
21 lines
367 B
Plaintext
-- tail recursion through higher-order functions
|
|
module test017;
|
|
|
|
open import Stdlib.Prelude;
|
|
|
|
sumb : Nat → (Nat → Nat → Nat) → Nat → Nat;
|
|
sumb acc f zero := acc;
|
|
sumb acc f (suc x) := f acc x;
|
|
|
|
terminating
|
|
sum' : Nat → Nat → Nat;
|
|
sum' acc x := sumb (x + acc) sum' x;
|
|
|
|
sum : Nat → Nat;
|
|
sum := sum' 0;
|
|
|
|
main : IO;
|
|
main := printNatLn (sum 10000);
|
|
|
|
end;
|