Esempio n. 1
0
File: vg.c Progetto: PlanetAPL/kona
//TODO: sort type-0 lists, functions, symbols, etc.
//note: K appears to sort _reserved functions by alphabetical order, but this may be a side effect of
//      sorting by address (if the functions appear in alphabetical order in the source file)
//      though oddly enough it appears to hold across all underscore/reserved functions (not just math)
//      _in falls to the end since it is defined as some variation on a char func that works as an inline verb
//      If you look at the binary the symbols appear to be listed out of alphabetical order
//one interesting way to test how functions are sorted would be to load the interpreter twice,
//inputting the same collection of functions each time but in a different order
//if the sort order changes for each instance then sorting is probably based on pointer/reference value
//if that fails then it may be necessary to look at distinctions between wordfunc,charfunc, valence, proj, etc
Z K grade_updown(K a, I r)
{
  I at=a->t, an=a->n;
  P(0< at, RE)
  if(-3==at) R charGrade(a,r);
  if(-1==at)
  {
    I x,u=II,v=-II;//MIN,MAX
    DO(an, x=kI(a)[i]; if(x<u)u=x; if(x>v)v=x;)  
    if(v-u < 87654321) R distributionGrade(a,r,u,v);//Magic Number
Esempio n. 2
0
File: vg.c Progetto: 0branch/kona
K grade_updown(K a, I r)
{
  I at=a->t, an=a->n;
  P(0< at, RE)
  if(-4==at)R symGrade(a,r);
  if(-3==at)R charGrade(a,r);
  if(-1==at||-2==at){
    K z;
    if(an<2){z=newK(-1,an);M(z);DO(an,kI(z)[i]=i);R z;}
    else{
      K x=0;uI y,u=(uI)-1,v=0,h=0,k;//MIN,MAX
      if(-2==at){x=newK(-1,an);M(x);}
      //trst();
      //elapsed("x=newK");
      if(-1==at)DO(an,y=kI(a)[i];h|=y;if(y<u)u=y;if(y>v)v=y)
      else DO(an,kU(x)[i]=(y=FtoI(kF(a)[i]));h|=y;if(y<u)u=y;if(y>v)v=y)
      //elapsed("fill x");
      //O("u:%016llx v:%016llx\n",u,v);
      if((r&&-1==at)||((u&MSB)!=(v&MSB))){
        u=(uI)-1;v=0;h=0;
        if(-1==at){
          x=newK(-1,an);M(x);
          DO(an,kU(x)[i]=(y=ItoU(kI(a)[i]));h|=y;if(y<u)u=y;if(y>v)v=y)}
        else DO(an,kU(x)[i]=(y=ItoU(kI(x)[i]));h|=y;if(y<u)u=y;if(y>v)v=y)}