Those are fast and lean, as you can see below.

   amr=: _1&^
   timespacex 'amr d'
0.002708 8.39027e6
   amr1=: {&_1 1
   timespacex 'amr1 d'
0.002657 8.39027e6


On Tue, Dec 11, 2012 at 2:39 AM, Roger Hui <[email protected]> wrote:
> Also {&_1 1 .
>
>
> On Mon, Dec 10, 2012 at 11:32 PM, Roger Hui <[email protected]>wrote:
>
>> 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 <[email protected]>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
>>>
>>
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm



-- 
(B=) <-----my sig
Brian Schott
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to