mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-22 21:35:03 +00:00
conversion functions
This commit is contained in:
parent
bde31f9eb3
commit
b0f22a19fe
@ -14,6 +14,24 @@ class Types implements ILib
|
|||||||
{
|
{
|
||||||
public function register(Env $env): void
|
public function register(Env $env): void
|
||||||
{
|
{
|
||||||
|
// Conversions
|
||||||
|
|
||||||
|
$env->set('to-bool', new CoreFunc('to-bool', 'Convert argument to boolean.', 1, 1,
|
||||||
|
fn ($a) => boolval($a)
|
||||||
|
));
|
||||||
|
|
||||||
|
$env->set('to-float', new CoreFunc('to-float', 'Convert argument to float.', 1, 1,
|
||||||
|
fn ($a) => floatval($a)
|
||||||
|
));
|
||||||
|
|
||||||
|
$env->set('to-int', new CoreFunc('to-int', 'Convert argument to integer.', 1, 1,
|
||||||
|
fn ($a) => intval($a)
|
||||||
|
));
|
||||||
|
|
||||||
|
$env->set('to-str', new CoreFunc('fn?', 'Convert argument to string.', 1, 1,
|
||||||
|
fn ($a) => strval($a)
|
||||||
|
));
|
||||||
|
|
||||||
// Test types
|
// Test types
|
||||||
|
|
||||||
$env->set('type?', new CoreFunc('type?', 'Return the type of argument as a string.', 1, 1,
|
$env->set('type?', new CoreFunc('type?', 'Return the type of argument as a string.', 1, 1,
|
||||||
|
Loading…
Reference in New Issue
Block a user