Re: Max Consecutive Occurrence.
- To: mathgroup at smc.vnet.net
- Subject: [mg47673] Re: Max Consecutive Occurrence.
- From: "Mariusz Jankowski" <mjankowski at usm.maine.edu>
- Date: Wed, 21 Apr 2004 05:23:14 -0400 (EDT)
- Organization: University of Southern Maine
- References: <c62k0d$rhi$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Bob, use tmp=Split[{1,1,2,2,2,-1,0,3,3,3,5}]; occur = Length/@tmp; now, Max[occur] will give you the count, while tmp[[ Flatten[Position[ occur, Max[ occur ] ] ] ]] will give you the actual list(s) Mariusz >>> Robert G. Wilson v<rgwv at rgwv.com> 4/20/2004 3:37:49 AM >>> Mathematica had many programmed functions which are not referenced in the help index. Under '?Position -> Further Examples' you will find two such functions, 'ConsecutiveOccurrences1' and 'ConsecutiveOccurrences2.' I first wish that Mathematica would index these. But the reason for writing is that I have a need for a function named 'MaxConsecutiveOccurrence' which would return the maximum consecutive occurrence of x in a list. Thank you in advance. Bob.