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, > > Rajanikanth
Here is an idea. It is not the most efficient code! def combine(l, a): if not l or l[-1]<a: l.append(a) return l reduce(combine, [0,1,2,3,0,1,2,2,3], []) best regards, beginner -- http://mail.python.org/mailman/listinfo/python-list