I'm asked to create a For[]
loop that will sum positive numbers in a list. I am unsure of how to do this.
For[i = 0, i <= Length[List], i += 1, result += i];
result
This is what i have so far where List is the list of numbers and result is the summation of all the positive numbers. I am aware this is not right though.
For[]
. $\endgroup$Total@*Ramp
... It is vectorized and thus much more efficient thatn top-level loops. $\endgroup$list.Unitize[Ramp[list]]
. $\endgroup$list.UnitStep@list
$\endgroup$