Unimodal Sequence

Author

Eric W. Weisstein
August 7, 2008

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

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

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

Code

UnimodalQ[a_List]:=Module[{m=Ordering[a,-1][[1]]},
LessEqual@@Take[a,m]&&GreaterEqual@@Drop[a,m]
]

Examples

<<Utilities`Plot`

ListPlot[l={1,2,4,5,6,6,4,4,2},Joined->True,PlotStyle->Red]
UnimodalQ[l]

ListPlot[l={1,2,4,5,6,6,4,5,2},Joined->True,PlotStyle->Red]
UnimodalQ[l]