Running Maximum

Author

Eric W. Weisstein
October 5, 2003

This notebook downloaded from http://mathworld.wolfram.com/notebooks/IntegerSequences/RunningMaximum.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/RunningMaximum.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Code

RunningMaxima[l_]:=Rest[FoldList[Max,-Infinity,l]]
HighWaterMarks[l_]:=Module[{s=Split[RunningMaxima[l]]},
{First/@s,Most[FoldList[Plus,1,Length/@s]]}
]

Example

l=Table[Random[Integer,{1,10}],{10}]

RunningMaxima[l]

HighWaterMarks[l]