100 REM The operation of this program is described in the paper 110 REM "Permutation Lattices Revisited", written by George Markowsky 120 REM and published in Mathematical Social Sciences, 27 (1994), pp. 59-74 130 REM The program is copyrighted 2001 and maybe freely distributed 140 REM provided this notice is included in the program. 150 REM This program is designed to illustrate the principles discussed 160 REM in the paper. It is left to the user to adapt it to any particular 170 REM purpose. All risks associated with using this program are assumed 180 REM by the user. The code is provided as is for instructional purposes. 190 REM This computes joins of two permutations. Sample permutations are 200 REM given in the data below. 210 READ N 220 DIM IND1(N),IND2(N),PO(N) 230 FOR I = 1 TO N : READ J : LET IND1(J) = I : NEXT I 240 FOR I = 1 TO N : READ J : LET IND2(J) = I : NEXT I 250 LET PO(N) = 1 260 FOR I = N-1 TO 1 STEP -1 : LET I2 = N+1-I 270 FOR J = I TO N-1 280 IF (IND1(I2) > IND1(PO(J+1))) AND (IND2(I2) > IND2(PO(J+1))) THEN LET PO(J)=PO(J+1) ELSE LET PO(J) = I2 : GOTO 310 290 NEXT J 300 LET PO(N) = I2 310 NEXT I 320 DATA 7,3,1,7,4,6,5,2,4,7,3,2,6,5,1 330 FOR I = 1 TO N : PRINT PO(I); : NEXT I : PRINT