Re: Max Consecutive Occurrence.
- To: mathgroup at smc.vnet.net
- Subject: [mg47660] Re: Max Consecutive Occurrence.
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Wed, 21 Apr 2004 05:22:58 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <c62k0d$rhi$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
and
lst = {a, a, a, a, b, b, b, a, a, a, a, a, a, a, c, a, a, a, a, a, a, a,
a};
MaxConsecutiveOccurrence[lst_, what_] :=
Max[Length /@ Cases[Split[lst], {what ..}]]
does not what you want ??
Regards
Jens
"Robert G. Wilson v" wrote:
>
> 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.