Metropoli BBS
VIEWER: partito.c MODE: TEXT (ASCII)
/* Copyright (C) 1993 by Thomas Glen Smith.  All Rights Reserved. */
/* partito APL2 V1.0.0 *************************************************
* Called by partitn once the axis has been determined, and the result  *
* variable has been allocated.                                         *
***********************************************************************/
#define INCLUDES APLCB
#include "includes.h"
Aplcb partito(left, rite, out, axis)
Aplcb left, rite, out;
int axis; /* Relative 0. */
{
	Axispre; Dtacopy; Errstop; Getcb; Partitp;
	int bot,botcnt,i,j,k,lead,m,n,oaxi,oaxicnt,p,raxi,raxicnt,top,
		topcnt,trail;

	for (;;) {	
		if (OK != axispre(rite,axis+1,&raxicnt,&botcnt,&topcnt)) break;
		for (top = 0; top < topcnt; top++) {
			lead = n = trail = 0; /* Initialize counters. */
			for (oaxi = raxi = j = p = 0; raxi < raxicnt; raxi++) {
				k = (j < (m = *(left->aplptr.aplint + raxi)));
					/* New items are created in the result     */
					/* whenever the corresponding item of left */
					/* is greater than the prior item of left. */
				j = m; /* Save for next iteration. */
				if (k && n) { /* Create new output? */
					partitp(out,rite,lead,n,trail,top,oaxi++,raxi,
						botcnt,axis);
					lead = n = trail = 0; /* Reset counters. */
				}
				(j) ? n++ : (n) ? trail++ : lead++; 
					/* Lead and trail are items to drop. */
			}
			partitp(out,rite,lead,n,trail,top,oaxi,raxi,botcnt,axis);
		}
		break; /* final break from outer for(;;) */
	}
     return(errstop(0,left,rite,out));
}
[ RETURN TO DIRECTORY ]