mlox/lox.t/function/mutual_recursion.lox

12 lines
204 B
Lox
Raw Normal View History

2024-08-03 02:44:12 +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