Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15635 > unrolled thread

Re: Pattern matching in lists

Started byDaniel Lichtblau <danl@wolfram.com>
First post2011-02-03 10:26 +0000
Last post2011-02-04 06:43 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Pattern matching in lists Daniel Lichtblau <danl@wolfram.com> - 2011-02-03 10:26 +0000
    Re: Pattern matching in lists Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-02-04 06:43 +0000

#15635 — Re: Pattern matching in lists

FromDaniel Lichtblau <danl@wolfram.com>
Date2011-02-03 10:26 +0000
SubjectRe: Pattern matching in lists
Message-ID<iidvsg$bfm$1@smc.vnet.net>
----- Original Message -----
> From: "Harvey P. Dale" <hpd1@nyu.edu>
> To: mathgroup@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



[toc] | [next] | [standalone]


#15997

FromArmand Tamzarian <mike.honeychurch@gmail.com>
Date2011-02-04 06:43 +0000
Message-ID<iig75k$rkk$1@smc.vnet.net>
In reply to#15635
On Feb 3, 9:26 pm, Daniel Lichtblau <d...@wolfram.com> wrote:
> ----- Original Message -----
> > From: "Harvey P. Dale" <h...@nyu.edu>
> > To: mathgr...@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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web