1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-05-01 02:31:23 -07:00

Implement apply.

Copied from Perforce
 Change: 180269
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Gareth Rees 2012-11-02 12:44:20 +00:00
parent 468a79a99c
commit a33c71a346

View file

@ -2049,6 +2049,21 @@ static obj_t entry_procedurep(obj_t env, obj_t op_env, obj_t operator, obj_t ope
}
/* (apply proc args)
* Proc must be a procedure and args must be a list. Calls proc with
* the elements of args as the actual arguments.
* See R4RS 6.9.
*/
static obj_t entry_apply(obj_t env, obj_t op_env, obj_t operator, obj_t operands)
{
obj_t proc, args;
eval_args(operator->operator.name, env, op_env, operands, 2, &proc, &args);
unless(TYPE(proc) == TYPE_OPERATOR)
error("%s: first argument must be a procedure", operator->operator.name);
return (*proc->operator.entry)(env, op_env, operator, args);
}
static obj_t entry_add(obj_t env, obj_t op_env, obj_t operator, obj_t operands)
{
obj_t args;
@ -3059,6 +3074,7 @@ static struct {char *name; entry_t entry;} funtab[] = {
{"negative?", entry_negativep},
{"symbol?", entry_symbolp},
{"procedure?", entry_procedurep},
{"apply", entry_apply},
{"+", entry_add},
{"-", entry_subtract},
{"*", entry_multiply},