/* Run time library for Hi */ #include #include #ifdef BOEHM #include #endif typedef int * word; word kkkl; #define STEP (sizeof(kkkl)) word callindirect(word*); int main() { int code =HiMain(); printf(" \n",code); exit(0); } word* sysvecalloc(word num){ word * res= (word*)malloc(((long)num)*STEP+STEP); res[0]=num; return res; } word putNum(word x){printf("%d\t",x);return x;} word getNum(){word a; scanf("%d",&a);return a;} word putChar(word x){ printf("%c",x); return x; } int getChar(){return getchar();} word* iota(word num) { word * res = sysvecalloc(num); long i; for(i=1;i<=(long)num;i++)res[i]=(word)i; return res; } word * vconcat(word * x, word * y) { word * res = sysvecalloc((word)((long)x[0]+(long)y[0])); int i,j; for(i=1;i<=(long)x[0];i++)res[i]=x[i]; for(i=1,j=((long)(x[0]))+1;i<=(long)y[0];i++,j++)res[j]=y[i]; return res; } /* applies proc to the parameters having indexed the parameters whose excess ranks are encoded in a vector of integers. Overloading encodes the rank of the result returned by map */ word * applytoall(int overloading,word * excessranks,word proc, word * params) { word * carrier,*tmp,*excess,*tmp2; long i,j,l,bound; l=(long)params[0]; if(overloading==0){ carrier=sysvecalloc((word)(l+1)); carrier[ 1]=proc; for(i=1;i<=l;i++) carrier[i+1]=params[i]; return(word*) callindirect(carrier); } else { carrier=sysvecalloc((word)l); bound=0x7fffffff; /*for(i=1;i<=l;i++)printf("param %d = %d excess = %d\n",i,params[i],excessranks[i]);*/ for(i=1;i<=l;i++){ if(excessranks[i]) { tmp= (word *) params[i]; if((long)tmp[0]