Isn't ([*[+])/\. 1 0 1 1 1 0 1 the same as ([*+)/\. 1 0 1 1 1 0 1 ?
Den 21:10 torsdag den 23. oktober 2014 skrev Joe Bogner <[email protected]>: > > >This can also answer the question in a backwards, slower sense: > >([*[+])/\. 1 0 1 1 1 0 1 > > >1 0 3 2 1 0 1 > > > >On Wed, Oct 22, 2014 at 2:12 PM, R.E. Boss <[email protected]> wrote: > >> >> }.;([:<+/\);.1[ 0,x >> 0 1 2 3 0 1 2 3 0 1 2 0 0 1 0 0 0 0 1 2 >> >> >> R.E. Boss >> >> (Add your info to http://www.jsoftware.com/jwiki/Community/Demographics ) >> >> >> > -----Original Message----- >> > From: [email protected] [mailto:programming- >> > [email protected]] On Behalf Of Roger Hui >> > Sent: woensdag 22 oktober 2014 19:25 >> > To: Programming forum >> > Subject: Re: [Jprogramming] count of consecutive 1s >> > >> > x >> > 0 1 1 1 0 1 1 1 0 1 1 0 0 1 0 0 0 0 1 1 >> > s->./\(-.x)*s=.+/\x >> > 0 1 2 3 0 1 2 3 0 1 2 0 0 1 0 0 0 0 1 2 >> > >> > >> > >> > On Wed, Oct 22, 2014 at 10:21 AM, Roger Hui <[email protected]> >> > wrote: >> > >> > > You can probably do better than the following, but it'd be useful as a >> > > result checker: >> > > >> > > ] x=: 0<20 ?@$ 3 >> > > 0 1 1 1 0 1 1 1 0 1 1 0 0 1 0 0 0 0 1 1 >> > > }. ; +/\&.> <;.1 ] 0,x >> > > 0 1 2 3 0 1 2 3 0 1 2 0 0 1 0 0 0 0 1 2 >> > > >> > > >> > > >> > > >> > > On Wed, Oct 22, 2014 at 10:10 AM, Joe Bogner <[email protected]> >> > wrote: >> > > >> > >> This is probably easy but I can't figure it out. How can I count the >> > >> number >> > >> of consecutive 1s? >> > >> >> > >> Another way to think about it is a running sum that resets upon >> hitting >> a >> > >> zero >> > >> >> > >> input=:1 0 1 1 1 1 0 1 >> > >> >> > >> expected=: 1 0 1 2 3 4 0 1 >> > >> ---------------------------------------------------------------------- >> > >> For information about J forums see >> > http://www.jsoftware.com/forums.htm >> > >> >> > > >> > > >> > ---------------------------------------------------------------------- >> > For information about J forums see http://www.jsoftware.com/forums.htm >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> >---------------------------------------------------------------------- >For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
