Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/23/scramb.sim
There is 1 other file named scramb.sim in the archive. Click here to see a list.
OPTIONS(/E/C/-Q/-A/-I/-D);
COMMENT   - Permutation Procedure -

Scramble will perform a Random permutation of element values
in the integer array INTARRAY in the interval [BOTTOM:TOP].
Thus the declared bounds of INTARRAY must not be inside that interval.
U is the conventional random drawing parameter.
;

PROCEDURE scramble(intarray,bottom,top,u);   NAME u;
INTEGER ARRAY intarray;   INTEGER bottom,top,u;
BEGIN   INTEGER swap,select,u1;

    OPTIONS(/A);	! Switch Array Bound Checking On;
    swap:= intarray[bottom];   swap:= intarray[top];;
    OPTIONS(/-A);	! Switch Array Bound Checking Off;
    u1:= u;
    WHILE top > bottom DO
    BEGIN
	select:= Randint(bottom,top,u1);
	IF select < top THEN
	BEGIN
	    swap:= intarray[select];
	    intarray[select]:= intarray[top];
	    intarray[top]:= swap;
	END;
	top:= top - 1
    END narrowing loop;
    u:= u1
END of Scramble;