[Jprogramming] Operations on boolean lists
Roger Hui
rhui000 at shaw.ca
Fri Oct 14 06:40:08 HKT 2011
+./@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
More information about the Programming
mailing list