optimize: remove array_map

This commit is contained in:
Pekka Laiho 2020-06-05 15:55:38 +07:00
parent 7331cbe874
commit 18277d9566

View File

@ -202,10 +202,12 @@ class Evaller
if ($ast instanceof Symbol) {
// Lookup symbol from env
return $env->get($ast->getName());
} elseif ($ast instanceof MList) {
return new MList(array_map(fn ($a) => $this->eval($a, $env), $ast->getData()));
} elseif ($ast instanceof Vector) {
return new Vector(array_map(fn ($a) => $this->eval($a, $env), $ast->getData()));
} elseif ($ast instanceof Seq) {
$results = [];
foreach ($ast->getData() as $val) {
$results[] = $this->eval($val, $env);
}
return $ast::new($results);
} elseif ($ast instanceof Hash) {
$results = [];
foreach ($ast->getData() as $key => $val) {