[Jprogramming] convert 0,1 coding to _1,1

Peter B. Kessler Peter.B.Kessler at Oracle.COM
Tue Dec 11 00:52:39 UTC 2012


Double the distance between 0 and 1, and then shift those points left one unit on the number line.

       am2=: ((-&1) @ +:)
       am2"1] 2 6 ?.@$ 2 
    _1 _1 _1 _1 1 _1
    _1 _1 _1  1 1 _1

Does that make sense?

			... peter

Brian Schott wrote:
> Is there a better way than the verb `am` to do the following?
> 
>    am =:_1& (I.@:-.@]})
>    am"1] 2 6 ?.@$ 2
> _1 _1 _1 _1 1 _1
> _1 _1 _1  1 1 _1
> 
> (B=)
> 
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm


More information about the Programming mailing list