I have a List[Double]
with the following values:
{-1.2200000000000006, -1.3200000000000003, -1.0099999999999998, 22.22, 11.11,
-31.310000000000002, -0.9799999999999986,-4, -5, 3, 2, 2.959999999999999}`
I was to find the max sum of the consecutive negative numbers.
So from original list to separate consecutive lists of negative and positive
{
{-1.2200000000000006, -1.3200000000000003, -1.0099999999999998},
{22.22, 11.11},
{-31.310000000000002, -0.9799999999999986,-4, -5},
{3, 2, 2.959999999999999}
}
then remove the positive consecutive numbers
{
{-1.2200000000000006, -1.3200000000000003, -1.0099999999999998},
{-31.310000000000002, -0.9799999999999986,-4, -5}
}
then sum
{-3.5500000000000007, -41.29}
then change to absolute values
{3.5500000000000007, 41.29}
then find max = 41.29