added lambda? predicate
This commit is contained in:
parent
3d344fc649
commit
746dceff43
@ -2,7 +2,7 @@
|
||||
|
||||
## Language Syntax
|
||||
|
||||
A HCL program is composed of more expressions.
|
||||
A HCL program is composed of expressions.
|
||||
|
||||
## Keywords
|
||||
* nil
|
||||
@ -64,12 +64,16 @@ A HCL program is composed of more expressions.
|
||||
|
||||
## Defining a function
|
||||
|
||||
```
|
||||
(defun function-name (arguments)
|
||||
| local variables |
|
||||
function body
|
||||
)
|
||||
```
|
||||
|
||||
```
|
||||
(set function-name (lambda (arguments)
|
||||
| local variables |
|
||||
function body
|
||||
)
|
||||
```
|
||||
|
11
lib/prim.c
11
lib/prim.c
@ -400,6 +400,16 @@ static hcl_pfrc_t pf_is_dictionary (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
HCL_STACK_SETRET (hcl, nargs, rv);
|
||||
return HCL_PF_SUCCESS;
|
||||
}
|
||||
|
||||
static hcl_pfrc_t pf_is_lambda (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_t rv, x;
|
||||
x = HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
rv = (HCL_IS_CONTEXT(hcl, x))? hcl->_true: hcl->_false;
|
||||
HCL_STACK_SETRET (hcl, nargs, rv);
|
||||
return HCL_PF_SUCCESS;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static hcl_pfrc_t pf_not (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
@ -764,6 +774,7 @@ static pf_t builtin_prims[] =
|
||||
{ 1, 1, pf_is_array, 6, { 'a','r','r','a','y','?' } },
|
||||
{ 1, 1, pf_is_bytearray, 10, { 'b','y','t','e','a','r','r','a','y','?' } },
|
||||
{ 1, 1, pf_is_dictionary, 11, { 'd','i','c','t','i','o','n','a','r','y','?' } },
|
||||
{ 1, 1, pf_is_lambda, 7, { 'l','a','m','b','d','a','?' } },
|
||||
|
||||
|
||||
{ 1, HCL_TYPE_MAX(hcl_oow_t), pf_number_add, 1, { '+' } },
|
||||
|
Loading…
Reference in New Issue
Block a user