tco for case

This commit is contained in:
Pekka Laiho 2020-06-04 21:39:26 +07:00
parent cb1a03e9bd
commit 8cf2dbeeec

View File

@ -48,13 +48,15 @@ class Evaller
for ($i = 1; $i < $ast->count() - 1; $i += 2) {
$test = $this->eval($ast->get($i), $env);
if ($test == true) {
return $this->eval($ast->get($i + 1), $env);
$ast = $ast->get($i + 1);
continue 2; // tco
}
}
// Last value, no test
if ($ast->count() % 2 == 0) {
return $this->eval($ast->get($ast->count() - 1), $env);
$ast = $ast->get($ast->count() - 1);
continue; // tco
} else {
return null;
}