[Jprogramming] convert 0,1 coding to _1,1
Roger Hui
rogerhui.canada at gmail.com
Tue Dec 11 07:32:11 UTC 2012
If you really are converting random boolean values to (1,_1) values,
another possibility is _1&^ or _1^]; i.e. 0 to 1 and 1 to _1.
On Mon, Dec 10, 2012 at 8:58 PM, Brian Schott <schott.brian at gmail.com>wrote:
> timespacex
> 6!:2 , 7!:2@]
> am =:_1& (I.@:-.@]})
> am2=: ((-&1) @ +:)
> amd=: <:@:+:
> aml=: _1 + +:
> d=: 2 6 50000?.@$ 2
> timespacex 'am"1 d'
> 0.011278 1.05535e7
> timespacex 'am2 d'
> 0.187884 8.39091e6
> timespacex 'amd d'
> 0.004365 1.6779e7
> timespacex 'aml d'
> 0.004874 1.67789e7
>
> It looks like David's method is fastest and Peter's is most lean.
> And Linda's method loses nothing relative to David's.
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
More information about the Programming
mailing list