Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: Pattern matching in lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116186] Re: Pattern matching in lists
  • From: Armand Tamzarian <mike.honeychurch at gmail.com>
  • Date: Fri, 4 Feb 2011 01:40:48 -0500 (EST)
  • References: <iidvsg$bfm$1@smc.vnet.net>

On Feb 3, 9:26 pm, Daniel Lichtblau <d... at wolfram.com> wrote:
> ----- Original Message -----
> > From: "Harvey P. Dale" <h... at nyu.edu>
> > To: mathgr... at smc.vnet.net
> > Sent: Wednesday, February 2, 2011 5:07:02 AM
> > Subject:  Pattern matching in lists
> > MemberQ easily tests whether a single integer appears in a list
> > of integers. Suppose, however, that I want to test not for a single
> > integer but for two or more consecutive integers, e.g., to see whether
> > {1,4,6} is a member of {1,3,2,6,5,1,4,6,3,9}. I can do this by
> > converting both lists into strings and then using string-matching
> > functions, but is there some way of doing it directly without that
> > conversion?
>
> > Thanks.
>
> > Harvey
>
> > Harvey P. Dale
> > [...]
>
> In[7]:= Or @@
>  ListCorrelate[{1, 4, 6}, {1, 3, 2, 6, 5, 1, 4, 6, 3, 9}, {-1, 1}, {},
>    Equal, And]
>
> Out[7]= True
>
> I've no idea why all the optional arguments to ListConvolve/Correlate were not made into Options. This strikes me as a particularly flawed aspect in the design of these otherwise excellent functions.
>
> Daniel Lichtblau
> Wolfram Research


It is a very useful function but can run quite a bit slower when you
replace the default Plus and Times with two different functions ---
which is a shame cause I like using this one, you can be quite
inventive with it.

Mike


  • Prev by Date: Re: phase portraits
  • Next by Date: Re: How to export a large Grid/Table on a single PDF page?
  • Previous by thread: Re: Pattern matching in lists
  • Next by thread: Re: DesignerUnits 2011-01-08 for Mathematica 8, 7, 6