[Jprogramming] All rotations of a rank 1 vector

Nollaig MacKenzie nollaig at amhuinnsuidhe.net
Sun Mar 24 04:24:57 UTC 2013


I like the anagram function:

   v
10 11 12
   rr
A.~ i.@:!@:#
   rr v
10 11 12
10 12 11
11 10 12
11 12 10
12 10 11
12 11 10

On 2013.03.24 15:20:35, you,
 the extraordinary Ric Sherlock, spake thus:

> Something like this might work :
> 1 2 3 |."0 1 ] 10 11 12
> Otherwise you should probably look at A.
> ({~ i.@!@# A. i.@#) 'abc'
> On Mar 24, 2013 2:55 PM, "Alex Giannakopoulos" <aegean at blueyonder.co.uk>
> wrote:
> 
> > I need to get all the rotations of a rank-1 vector
> > i.e from 10 11 12  to get  10 11 12, 11 12 10 and 12 10 11
> >
> > say my vector is size 3, I tried:
> >   i.3  |. 10 11 12
> > but it spits out a length error, as, of course, does  0 1 2 |. 10 11 12
> > Trying to change the rank of rotate doesn't seem to help, not how I'm doing
> > it, anyhow.
> >
> > Any suggestions?

-- 
Nollaig MacKenzie
http://www.yorku.ca/nollaig


More information about the Programming mailing list