| 1 | <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 | <title>Permutation: Swap blocks...</title> |
| 3 | <style> |
| 4 | td { padding-left: 5pt; padding-right: 5pt; } |
| 5 | th { padding-left: 5pt; padding-right: 5pt; } |
| 6 | code { white-space: pre-wrap; } |
| 7 | dd { white-space: pre-wrap; } |
| 8 | </style> |
| 9 | </head><body bgcolor="#FFFFFF"> |
| 10 | |
| 11 | <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Palatino,Times" size=6 color="#999900"><b> |
| 12 | Permutation: Swap blocks... |
| 13 | </b></font></table></table> |
| 14 | <p>A command to swap the contents of two index ranges in the selected <a href="Permutation.html">Permutation</a>.</p> |
| 15 | <h2>Settings</h2> |
| 16 | <dl> |
| 17 | <dt><b>From index</b>, <b>To index</b> |
| 18 | <dd>the two starting positions from where elements are to be swapped. The blocks may overlap.</dd> |
| 19 | <dt><b>Block size</b> |
| 20 | <dd>determines the number of pairs to swap. </dd> |
| 21 | </dl> |
| 22 | <h2>Behaviour</h2> |
| 23 | <p>If the <b>Block size</b> equals one, only the elements at the <b>From index</b> and <b>To index</b> position are swapped. If blocksize is greater than one, the two elements at <b>From index</b>+1 and <b>To index</b>+1 will be swapped too. This goes on until the last two elements in each block have been swapped.</p> |
| 24 | <h2>Examples</h2> |
| 25 | <p>1. Swap two blocks: with <b>From index</b> = 1, <b>To index</b> = 4, and <b>Block size</b> = 2, the permutation (1,2,3,4,5) is turned into (4,5,3,1,2).</p> |
| 26 | <p>2. Swap two elements: with <b>From index</b> = 1, <b>To index</b> = 4, and <b>Block size</b> = 1, the permutation (1,2,3,4,5) is turned into (4,2,3,1,5).</p> |
| 27 | <p>3. Swap two overlapping blocks: with <b>From index</b> = 1, <b>To index</b> = 3, and <b>Block size</b> = 3, the permutation (1,2,3,4,5) is turned into (3,4,5,2,1).</p> |
| 28 | <hr> |
| 29 | <address> |
| 30 | <p>© djmw 20110105</p> |
| 31 | </address> |
| 32 | </body> |
| 33 | </html> |