Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15635 > unrolled thread
| Started by | Daniel Lichtblau <danl@wolfram.com> |
|---|---|
| First post | 2011-02-03 10:26 +0000 |
| Last post | 2011-02-04 06:43 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
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
| From | Daniel Lichtblau <danl@wolfram.com> |
|---|---|
| Date | 2011-02-03 10:26 +0000 |
| Subject | Re: 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]
| From | Armand Tamzarian <mike.honeychurch@gmail.com> |
|---|---|
| Date | 2011-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