| Conditions | 1 |
| Paths | 1 |
| Total Lines | 11 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | public function evaluate($program, Env\EnvInterface $env, Evaluator $evaluate) |
||
| 29 | { |
||
| 30 | // generate a lambda (eval the program *without* name) |
||
| 31 | // use that as the value in the define |
||
| 32 | // then call that |
||
| 33 | list($_let, $name, $bindings) = $program; |
||
| 34 | $body = \array_slice($program, 3); |
||
| 35 | $lambdaExp = array_merge([Symbol::make('lambda'), array_column($bindings, 0)], $body); |
||
| 36 | $defineExp = [Symbol::make('define'), $name, $lambdaExp]; |
||
| 37 | $evaluate($defineExp, $env); |
||
| 38 | return $evaluate(array_merge([$name], array_column($bindings, 1)), $env); |
||
| 39 | } |
||
| 40 | } |