[Jprogramming] Is right shift working properly?

Joe Bogner joebogner at gmail.com
Fri May 26 02:48:40 UTC 2017


_1 |.!.0 k
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0

(-1) |.!.0 k
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0

Right to left evaluation. Need to use _ to indicate a negative number

On May 25, 2017 10:41 PM, "Michael Rice" <limitcase at gmail.com> wrote:

> From the documentation:
>
>    |.!._ i.6     NB. Monad: |.!._ y (shift right 1) is same as Dyad: x
> |.!._ y with x=_1
> _ 0 1 2 3 4
>
> ====When I try it===
>
>   |.!._ i.6
> _ 0 1 2 3 4
>    |.!.0 i.6
> 0 0 1 2 3 4
>    _1 |.!._ i.6
> _ 0 1 2 3 4
>    _1 |.!.0 i.6
> 0 0 1 2 3 4
>    _2 |.!.0 i.6
> 0 0 0 1 2 3
>
> So far, so good.
>
> But...
>
>   k =: 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>    k
> 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>    -1 |.!.0 k
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>    -2 |.!.0 k
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>
> Why isn't k getting rotated right as i.6 was rotated?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm


More information about the Programming mailing list