示例#1
0
int apply(int func, int args){
	int symaddr,lamlis,body,res;
      
    symaddr = findsym(func);
    if(symaddr == 0)
      	error(CANT_FIND_ERR, "apply", func);
    else {
    	switch(GET_TAG(symaddr)){
        	case SUBR: 	return((GET_SUBR(symaddr))(args));
            case FSUBR:	return((GET_SUBR(symaddr))(args)); 			
            case LAMBDA: {	lamlis = car(GET_BIND(symaddr));
            				body = cdr(GET_BIND(symaddr));
                            bindarg(lamlis,args);
                            while(!(IS_NIL(body))){
                            	res = eval(car(body));
                                body = cdr(body);
                            }
                            unbind();
                            return(res); }      
        }
    }
}
示例#2
0
文件: mlis.c 项目: kzfm1024/misc
int apply(int func, int args){
    int symaddr,varlist,body,res;
      
    symaddr = findsym(func);
    if(symaddr == -1)
        error(CANT_FIND_ERR, "apply", func);
    else {
        switch(GET_TAG(symaddr)){
            case SUBR:  return((GET_SUBR(symaddr))(args));
            case FSUBR: return((GET_SUBR(symaddr))(args));          
            case FUNC: {    varlist = car(GET_BIND(symaddr));
                            body = cdr(GET_BIND(symaddr));
                            bindarg(varlist,args);
                            while(!(IS_NIL(body))){
                                res = eval(car(body));
                                body = cdr(body);
                            }
                            unbind();
                            return(res); }
            default:    error(ILLEGAL_OBJ_ERR, "eval", symaddr);      
        }
    }
    return(0);
}