mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-22 21:35:03 +00:00
convert symbol to string
This commit is contained in:
parent
437bf252c5
commit
b568ece8f0
@ -29,7 +29,7 @@ class Types implements ILib
|
||||
));
|
||||
|
||||
$env->set('str', new CoreFunc('str', 'Convert arguments to string and concatenate them together.', 0, -1,
|
||||
fn (...$args) => implode('', array_map('strval', $args))
|
||||
fn (...$args) => implode('', array_map([$this, 'getStrValue'], $args))
|
||||
));
|
||||
|
||||
$env->set('symbol', new CoreFunc('symbol', 'Convert argument to symbol.', 1, 1,
|
||||
@ -134,4 +134,13 @@ class Types implements ILib
|
||||
fn ($a) => $a % 2 !== 0
|
||||
));
|
||||
}
|
||||
|
||||
private function getStrValue($a)
|
||||
{
|
||||
if ($a instanceof Symbol) {
|
||||
return $a->getName();
|
||||
}
|
||||
|
||||
return strval($a);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user