I want to find the sum of all positive number that come before first negative number.
I got the following list in elixir.
iex(4)> steps = [0,1,2,3,-4,5,6,-1]
And I calculate the sum of this list as follows
Enum.reduce(steps,0,fn x,acc -> acc=acc+x end)
How to come out of reduce once we hit a negative number?