madlisp/lib.php

18 lines
364 B
PHP
Raw Normal View History

2020-05-27 09:27:47 +00:00
<?php
require_once('classes.php');
function ml_get_env(): Env
{
$env = new Env();
// basic arithmetic
$env->set('+', fn (...$args) => array_sum($args));
$env->set('-', fn ($a, $b) => $a - $b);
$env->set('*', fn ($a, $b) => $a * $b);
$env->set('/', fn ($a, $b) => $a / $b);
$env->set('%', fn ($a, $b) => $a % $b);
return $env;
}