#Apr11.txt: PS3(pi) to be finished! NewHelp:=proc(): print(` ApplyFlipsT(T,L) `): print(`ApplyFlips(pi,L), PS3(pi), EH(L), EHr(L)`): end: read `W:\\JB.txt`: read `W:\\Apr4.txt`: read `W:\\WTck.txt`: #ApplyFlipsT(T,L): applies the sequence of flips #in the list L to a padded type T, from LEFT to RIGHT ApplyFlipsT:=proc(T,L) local i,T1: T1:=T: for i from 1 to nops(L) do T1:=flipT(T1,L[i]): od: T1: end: #ApplyFlips(pi,L): applies the sequence of flips #in the list L to a permutation pi, from LEFT to RIGHT ApplyFlips:=proc(pi,L) local i,pi1: pi1:=pi: for i from 1 to nops(L) do pi1:=flip(pi1,L[i]): od: pi1: end: #EH(L): converts an INCREASING LIST of numbers #(starting at 1) to the list of differences EH:=proc(L) local i: [L[1],seq(L[i+1]-L[i],i=1..nops(L)-1)]: end: #reverse of EH EHr:=proc(L) local i: [seq( convert([op(1..i,L)], `+`),i=1..nops(L))]: end: #PS3(pi): A systematic adaptation of the Gates- #Papadimitriou prefix sorting algorithm #it inputs a permutation and outputs a list #of filps that makes it the identity permutation #(not necessarily optimal, but hopefully pretty close) PS3:=proc(pi) local T,Locs,brian, L1, MR: print(`Under construction!`): brian:=WhatTypeG(pi): T:=brian[1]: Locs:=brian[2]: L1:=BFTF(T): #MR(actual sequence of flips) MR:=[]: MR:=[Locs[L1[1]]]: for i from 2 to nops(L1) do od: end: