FOR i:
INT
IN [0..ops)
DO
s1, e1, s2, e2, s3, e3, tail: LIST OF REF;
a1: INT ¬ Random.ChooseInt[NIL, 0, rosary.Size];
a2: INT ¬ Random.ChooseInt[NIL, 0, rosary.Size];
IF a1 > a2 THEN {t: INT ~ a1; a1 ¬ a2; a2 ¬ t};
[s1, e1, tail] ¬ SplitOff[list, a1];
[s2, e2, tail] ¬ SplitOff[tail, a2-a1];
[s3, e3, tail] ¬ SplitOff[tail, rosary.Size-a2];
IF i
MOD 2 = 0
THEN {
list ¬ Join[s2, e2, s1, e1, s3];
rosary ¬ Rosary.Cat[Rosary.Substr[rosary, a1, a2-a1], Rosary.Substr[rosary, 0, a1], Rosary.Substr[rosary, a2, rosary.Size-a2]];
}
ELSE {
list ¬ Join[s1, e1, s3, e3, s2];
rosary ¬ Rosary.Cat[Rosary.Substr[rosary, 0, a1], Rosary.Substr[rosary, a2, rosary.Size-a2], Rosary.Substr[rosary, a1, a2-a1]];
};
IF paranoid THEN Check[[rosary], list];
ENDLOOP;