added lambda? predicate
This commit is contained in:
		| @ -2,7 +2,7 @@ | |||||||
|  |  | ||||||
| ## Language Syntax | ## Language Syntax | ||||||
|  |  | ||||||
| A HCL program is composed of more expressions. | A HCL program is composed of expressions. | ||||||
|  |  | ||||||
| ## Keywords | ## Keywords | ||||||
| * nil | * nil | ||||||
| @ -64,12 +64,16 @@ A HCL program is composed of more expressions. | |||||||
|  |  | ||||||
| ## Defining a function | ## Defining a function | ||||||
|  |  | ||||||
|  | ``` | ||||||
| (defun function-name (arguments) | (defun function-name (arguments) | ||||||
| 	| local variables | | 	| local variables | | ||||||
| 	function body | 	function body | ||||||
| ) | ) | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ``` | ||||||
| (set function-name (lambda (arguments) | (set function-name (lambda (arguments) | ||||||
| 	| local variables | | 	| local variables | | ||||||
| 	function body | 	function body | ||||||
| ) | ) | ||||||
|  | ``` | ||||||
|  | |||||||
| @ -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); | 	HCL_STACK_SETRET (hcl, nargs, rv); | ||||||
| 	return HCL_PF_SUCCESS; | 	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) | 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_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_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_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,  { '+' } }, | 	{ 1, HCL_TYPE_MAX(hcl_oow_t), pf_number_add,      1,  { '+' } }, | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user