Trailing-Edge - PDP-10 Archives - decuslib20-03 - decus/20-0078/libsim/scramb.sim
There is 1 other file named scramb.sim in the archive. Click here to see a list.
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
	select:= Randint(bottom,top,u1);
	IF select < top THEN
	    swap:= intarray[select];
	    intarray[select]:= intarray[top];
	    intarray[top]:= swap;
	top:= top - 1
    END narrowing loop;
    u:= u1
END of Scramble;