_1 0 2 |."0 1 m
 3  0 1 2
 4  5 6 7
10 11 8 9

   _1 0 2 |."_1 m
 3  0 1 2
 4  5 6 7
10 11 8 9



On Mon, Sep 10, 2012 at 12:17 AM, Gian Medri <gianme...@gmail.com> wrote:

> Hi!
> I want to rotate the rows in a matrix individually.
> In APL it is very simple, using the primitive "phi" :
>
> ]m=:i. 3 4
> 0 1  2  3
> 4 5  6  7
> 8 9 10 11
>
> ¯1 0 2 "phi" m
>  3  0 1 2
>  4  5 6 7
> 10 11 8 9
>
> The rotate primitive in J doesn't work in the same way, so I have done a
> verb with the same functionality as in APL.
>  ro=: [: > [ |.&.> [: <"1 ]
>
> _1 0 2   ro  m
>  3  0 1 2
>  4  5 6 7
> 10 11 8 9
>
> To me this verb looks too clumsy,  is there a better solution?
>
> Gian Medri
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to