mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-22 21:35:03 +00:00
optimize: remove array_map
This commit is contained in:
parent
7331cbe874
commit
18277d9566
@ -202,10 +202,12 @@ class Evaller
|
|||||||
if ($ast instanceof Symbol) {
|
if ($ast instanceof Symbol) {
|
||||||
// Lookup symbol from env
|
// Lookup symbol from env
|
||||||
return $env->get($ast->getName());
|
return $env->get($ast->getName());
|
||||||
} elseif ($ast instanceof MList) {
|
} elseif ($ast instanceof Seq) {
|
||||||
return new MList(array_map(fn ($a) => $this->eval($a, $env), $ast->getData()));
|
$results = [];
|
||||||
} elseif ($ast instanceof Vector) {
|
foreach ($ast->getData() as $val) {
|
||||||
return new Vector(array_map(fn ($a) => $this->eval($a, $env), $ast->getData()));
|
$results[] = $this->eval($val, $env);
|
||||||
|
}
|
||||||
|
return $ast::new($results);
|
||||||
} elseif ($ast instanceof Hash) {
|
} elseif ($ast instanceof Hash) {
|
||||||
$results = [];
|
$results = [];
|
||||||
foreach ($ast->getData() as $key => $val) {
|
foreach ($ast->getData() as $key => $val) {
|
||||||
|
Loading…
Reference in New Issue
Block a user