I have been searching this for a while, basically I am trying to conditionally increment a list of element by another list, element-wise...
my code is following, but is there a better way to do it? list comprehension, map??
I think a element-wise operator like ~+= from http://www.python.org/dev/peps/pep-0225/ would be really good, but why is it deferred?
for i in range(1,len(s)):
if s[i]<s[0]:
s[i]+=p[i]
based on some good feedbacks from you guys I have recoded to the following
i=s<s[0]
s[i]+=p[i]
and s,p are both arrays.
p.s still slow than matlab 5 times for one of my code.