--- stack/stack.c 2002/03/17 02:15:01 1.114 +++ stack/stack.c 2002/03/17 11:26:35 1.115 @@ -165,7 +165,7 @@ extern void gc_init(environment *env) { stackitem *new_head= NULL, *titem; - cons *iterator; + pair *iterator; symbol *tsymb; int i; @@ -285,7 +285,7 @@ { value *new_value= new_val(env); - new_value->content.c= malloc(sizeof(cons)); + new_value->content.c= malloc(sizeof(pair)); assert(new_value->content.c!=NULL); new_value->type= tcons; CAR(new_value)= val; @@ -1049,7 +1049,7 @@ } if(myenv.interactive) { - printf("Stack version $Revision: 1.114 $\n\ + printf("Stack version $Revision: 1.115 $\n\ Copyright (C) 2002 Mats Alritzson and Teddy Hogeborn\n\ Stack comes with ABSOLUTELY NO WARRANTY; for details type 'warranty;'.\n\ This is free software, and you are welcome to redistribute it\n\ @@ -1332,7 +1332,7 @@ break; case tcons: - new_value->content.c= malloc(sizeof(cons)); + new_value->content.c= malloc(sizeof(pair)); assert(new_value->content.c!=NULL); CAR(new_value)= copy_val(env, CAR(old_value)); /* recurse */ @@ -2353,3 +2353,29 @@ CAR(env->head)=CDR(CAR(env->head)); } + +extern void cons(environment *env) +{ + value *val; + + if(env->head->type==empty || CDR(env->head)->type==empty) { + printerr("Too Few Arguments"); + env->err= 1; + return; + } + + val=new_val(env); + val->content.c= malloc(sizeof(pair)); + assert(val->content.c!=NULL); + val->type=tcons; + + CAR(val)= CAR(CDR(env->head)); + CDR(val)= CAR(env->head); + + push_val(env, val); + + swap(env); if(env->err) return; + toss(env); if(env->err) return; + swap(env); if(env->err) return; + toss(env); if(env->err) return; +}