Re: split a list based on a predicate

2008-10-09 Thread Rajanikanth Jammalamadaka
Thanks for all of your replies. Rajanikanth On Wed, Oct 8, 2008 at 11:59 PM, beginner <[EMAIL PROTECTED]> wrote: > Hi, > > On Oct 8, 6:36 pm, "Rajanikanth Jammalamadaka" <[EMAIL PROTECTED]> > wrote: >> Hi! >> >> Is there a functional way to do this? >> >> I have an array [0,1,2,3,0,1,2,2,3] and I

Re: split a list based on a predicate

2008-10-09 Thread beginner
Hi, On Oct 8, 6:36 pm, "Rajanikanth Jammalamadaka" <[EMAIL PROTECTED]> wrote: > Hi! > > Is there a functional way to do this? > > I have an array [0,1,2,3,0,1,2,2,3] and I want the first chunk of > non-decreasing values from this array (eg: In this case I want > [0,1,2,3]) > > Thanks, > > Rajanika

Re: split a list based on a predicate

2008-10-08 Thread bearophileHUGS
Rajanikanth Jammalamadaka: > Is there a functional way to do this? > I have an array [0,1,2,3,0,1,2,2,3] and I want the first chunk of > non-decreasing values from this array (eg: In this case I want > [0,1,2,3]) In Python sometimes the best way to write the code isn't functional, this is readable

Re: split a list based on a predicate

2008-10-08 Thread Tim Chase
Is there a functional way to do this? I have an array [0,1,2,3,0,1,2,2,3] and I want the first chunk of non-decreasing values from this array (eg: In this case I want [0,1,2,3]) Sounds like a use for a generator wrapper: def monotonic(iterator): i = iter(iterator) prev = i.next()

split a list based on a predicate

2008-10-08 Thread Rajanikanth Jammalamadaka
Hi! Is there a functional way to do this? I have an array [0,1,2,3,0,1,2,2,3] and I want the first chunk of non-decreasing values from this array (eg: In this case I want [0,1,2,3]) Thanks, Rajanikanth -- http://mail.python.org/mailman/listinfo/python-list