MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Max Consecutive Occurrence.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47678] RE: [mg47653] Max Consecutive Occurrence.
  • From: "DrBob" <drbob at bigfoot.com>
  • Date: Wed, 21 Apr 2004 05:23:24 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Those aren't undocumented built-in functions; they're just examples. Here's
a maxConsecutiveCount that may do it for you:

Clear[helper, 
  maxConsecutiveCount]
helper[b_][a:{b_, ___}] := Length[a]
helper[b_][a_List] := 0
maxConsecutiveCount[m_List, x_] := Max[helper[x] /@ Split[mm]]

maxConsecutiveCount[mm, #1] &  /@ Union[mm]
maxConsecutiveCount[mm, d]
{5, 2, 3}
2

DrBob

www.eclecticdreams.net

-----Original Message-----
From: Robert G. Wilson v [mailto:rgwv at rgwv.com] 
To: mathgroup at smc.vnet.net
Subject: [mg47678] [mg47653] Max Consecutive Occurrence.


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.




  • Prev by Date: Re: Max Consecutive Occurrence.
  • Next by Date: Re: Max Consecutive Occurrence.
  • Previous by thread: Re: Max Consecutive Occurrence.
  • Next by thread: New polynomial set that yields a sequence set of real irrational numbers