Rob, Rotate by row/column was exactly what I needed, thanks! Tony, Wow! I didn't know that catalog worked like that! Thanks!
Skip Skip Cave Cave Consulting LLC On Mon, Jun 12, 2023 at 2:53 AM 'Rob Hodgkinson' via Programming < programm...@jsoftware.com> wrote: > See dyadic rotate ( > https://code.jsoftware.com/wiki/Vocabulary/bardot#dyadic) > > APL had rotate on either first or last axis, and J has rotate that can be > ‘adapted’ to do what you want using rank: > > ]s1=.4 4${(4#'ABCD'),.(-.&' ')":4#1234 > ┌──┬──┬──┬──┐ > │A1│A2│A3│A4│ > ├──┼──┼──┼──┤ > │B1│B2│B3│B4│ > ├──┼──┼──┼──┤ > │C1│C2│C3│C4│ > ├──┼──┼──┼──┤ > │D1│D2│D3│D4│ > └──┴──┴──┴──┘ > > 0 1 2 3 |."0 1 s1 NB. Rotate Item 1 by 0, Item 2 by 1 > (left), Item 3 by 2 (left), Item 4 by 3 (left) > ┌──┬──┬──┬──┐ > │A1│A2│A3│A4│ > ├──┼──┼──┼──┤ > │B2│B3│B4│B1│ > ├──┼──┼──┼──┤ > │C3│C4│C1│C2│ > ├──┼──┼──┼──┤ > │D4│D1│D2│D3│ > └──┴──┴──┴──┘ > > 0 1 2 3 |."0 1&.|: s1 NB. This same as above but uses &. > (And it’s inverse) to transpose the matrix before and after the rotate, so > that the same operation now works column wise > ┌──┬──┬──┬──┐ > │A1│B2│C3│D4│ > ├──┼──┼──┼──┤ > │B1│C2│D3│A4│ > ├──┼──┼──┼──┤ > │C1│D2│A3│B4│ > ├──┼──┼──┼──┤ > │D1│A2│B3│C4│ > └──┴──┴──┴──┘ > > Is this what you are after Skip ? HTH, Rob > > > On 12 Jun 2023, at 5:34 pm, 'Skip Cave' via Programming < > programm...@jsoftware.com> wrote: > > > > I can generate a 4x4 square with unique identifiers in each square: > > > > ]s1=.4 4${(4#'ABCD'),.(-.&' ')":4#1234 > > > > ┌──┬──┬──┬──┐ > > > > │A1│A2│A3│A4│ > > > > ├──┼──┼──┼──┤ > > > > │B1│B2│B3│B4│ > > > > ├──┼──┼──┼──┤ > > > > │C1│C2│C3│C4│ > > > > ├──┼──┼──┼──┤ > > > > │D1│D2│D3│D4│ > > > > └──┴──┴──┴──┘ > > > > How can I rotate each row a different amount? > > > > I want to rotate row zero 0 cells left, row 1 one cell left, row 2 two > > cells left, & row three 3 cells left? > > > > > > How to do the same for columns? > > > > Skip Cave > > Cave Consulting LLC > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm