       Rearranging & Restructuring Lists: Changing pattern order in

• To: mathgroup at smc.vnet.net
• Subject: [mg98788] Rearranging & Restructuring Lists: Changing pattern order in
• From: mediatalk <nick.maj at mssm.edu>
• Date: Sun, 19 Apr 2009 04:54:16 -0400 (EDT)

```Introduction:

Pattern A is based on the square of "a" and consists of "aSqrA": "a" repeated "Quotient[a*a,a]" times, bSqrA: "b...b(a-b+1)" repeated "(a+b)/b" times with each aditional "b" shifted by "a", and rSqrA: the result of Union[aSqrA,bSqrA].

Pattern B is based on the common product of "a" and "b" and consists of "aCp": "a" repeated "b" times, bCp: "b" repeated "a" times , and rCp: the result of Union[aCp,bCp]. Pattern B is shifted by "a*a".

Timeline view with a = 5, b = 2. x's representing the start time.

xooooxooooxooooxooooxooooxooooxoooo = a
xoxoxoxoxooooooooooooooooxoxoxoxoxo = b
oooooxoxoxoxoxooooooooooooooooooooo = b2
ooooooooooxoxoxoxoxoooooooooooooooo = b3
oooooooooooooooxoxoxoxoxooooooooooo = b4
xoxoxxxxxxxxxxxxxxxxxxoxoxoxoxxxoxo = r

a = 5; b = 2;

(*  Pattern A , Start = 0, End = a*a  -----------------------------*)

aSqrA = Flatten[Table[Partition[Range[
i , a ^2 + i, a], 2, 1], {i, 0, a ^2 - 1 , a ^2}], 1];

bSqrA = Table[Flatten[Table[Partition[Range[
i , a*b + i, b], 2, 1], {i, j a, a ^2 - 1, a ^2}], 1], {j, 0,
a - b, 1}];

rSqrA = Flatten[Table[Partition[Union[Range[
i, a ^2 + i , a], Flatten[bSqrA, 1][[All, 1]]], 2, 1], {i, 0,
a ^2 - 1, a ^2}], 1];

(*  Pattern B , Start = 0+a*a, End = a*a+a*b  ----------------------*)

aCp = Flatten[Table[Partition[Range[
i , a*b + i, a], 2, 1], {i, a ^2, (a*b - 1) + a ^2, a*b}], 1];

bCp = Flatten[Table[Partition[Range[
i , a*b + i, b], 2, 1], {i, a ^2, (a*b - 1) + a ^2, a*b}], 1];

rCp = Flatten[Table[Partition[Union[Flatten[Range[
i, a*b + i, {a, b}]]], 2, 1], {i, a ^2, (a*b - 1) + a ^2,
a*b}], 1];

(*  Pattern A and B ------------------------------------------*)

Join[aSqrA, aCp]
Union[Flatten[bSqrA, 1], bCp]
Join[rSqrA, rCp]

Problem:

How can I reverse the pattern order so that B starts and A comes after B.
I need the output of each generator. (aSqrA, aCp... etc.)