[Jprogramming] Operations on boolean lists
Thomas Costigliola
tcostigl at gmail.com
Fri Oct 14 08:46:34 HKT 2011
Thanks for the heads up. Now I have to check all the 1&e. in my code.
At least for rank 1 Boolean arguments it seems like +./ and 1&e.
should execute the same code so as not to tax the un-enlightened.
On Thu, Oct 13, 2011 at 6:40 PM, Roger Hui <rhui000 at shaw.ca> wrote:
> +./@E. is backed by special code. Thus:
>
> ts=: 6!:2 , 7!:2@]
>
> b=: 0<1e6 ?@$ 4
> ts '(42$1) +./@E. b'
> 0.000961575 1600
> ts '42 (1 e. ([#1:) E. ]) b'
> 0.00308224 1.05018e6
>
> Another phrase finds the maximum number of
> consecutive 1s: cut where b has a 1 preceded
> by a 0, and sum the cut.
>
> >./ (b>}:0,b) +/;.1 b
> 42
> ts '>./ (b>}:0,b) +/;.1 b'
> 0.0198919 4.19635e6
>
>
>
> ----- Original Message -----
> From: Thomas Costigliola <tcostigl at gmail.com>
> Date: Thursday, October 13, 2011 15:18
> Subject: Re: [Jprogramming] Operations on boolean lists
> To: Programming forum <programming at jsoftware.com>
>
>> N (1 e.([#1:)E.]) 1 0 ...
>>
>> On Oct 13, 2011 5:58 PM, "David Vaughan"
>> <purpleblues13 at googlemail.com>wrote:
>> >
>> > How could I test if a boolean list contains at least n
>> consecutive 1's?
>> >
>> > e.g. for 3 consecutive 1's:
>> >
>> > desiredverb 0 1 1 1 0 0
>> > 1
>> > desiredverb 0 1 1 0 1 1
>> > 0
>> > desiredverb 1 1 1 1 1 0
>> > 1
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
More information about the Programming
mailing list