rlox/interpreter/tests/lox/function/mutual_recursion.lox

12 lines
204 B
Lox
Raw Permalink Normal View History

2024-09-01 19:15:55 +02:00
fun isEven(n) {
if (n == 0) return true;
return isOdd(n - 1);
}
fun isOdd(n) {
if (n == 0) return false;
return isEven(n - 1);
}
print isEven(4); // expect: true
print isOdd(3); // expect: true