16 lines
421 B
Text
16 lines
421 B
Text
greatest_subsequential_sum_it([]) = [] => true.
|
|
greatest_subsequential_sum_it(A) = Seq =>
|
|
P = allcomb(A),
|
|
Total = max([Tot : Tot=_T in P]),
|
|
Seq1 = [],
|
|
if Total > 0 then
|
|
[B,E] = P.get(Total),
|
|
Seq1 := [A[I] : I in B..E]
|
|
else
|
|
Seq1 := []
|
|
end,
|
|
Seq = Seq1.
|
|
|
|
allcomb(A) = Comb =>
|
|
Len = A.length,
|
|
Comb = new_map([(sum([A[I]:I in B..E])=([B,E])) : B in 1..Len, E in B..Len]).
|