Same but more readable for me:

     hcinv2
  (2 #. ])`((2 #. }.) - 2 ^ [: <: #)@.{."1

     hcinv2 hc i:5
  _5 _4 _3 _2 _1 0 1 2 3 4 5

On 12/10/2011 12:01 AM, Kip Murray wrote:
> Now we need an inverse for Raul's improved #: ("hash colon")
>
>       hc  NB. Raul's improved #:
>    {.@#:@(,: (2 * |))
>
>       hc i: 2
>    1 1 0
>    1 1 1
>    0 0 0
>    0 0 1
>    0 1 0
>
>       hcinv  NB. improvement sought
>    2&#.`(2&#.@}. - 2 ^<:@#)@.{."1
>
>       hcinv hc i: 2
>    _2 _1 0 1 2
>
> On 12/8/2011 2:41 PM, Raul Miller wrote:
> ...
> But this would work just as well, as a model:
>
>       {.@#:@(,:  2 * |)i:2
>    1 1 0
>    1 1 1
>    0 0 0
>    0 0 1
>    0 1 0
> ----------------------------------------------------------------------
> 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