Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15803
| From | Andrzej Kozlowski <akoz@mimuw.edu.pl> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Pattern matching in lists |
| Date | 2011-02-02 12:05 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <iibhai$ooq$1@smc.vnet.net> (permalink) |
| References | <201102021107.GAA24311@smc.vnet.net> |
On 2 Feb 2011, at 20:07, Harvey P. Dale wrote:
> 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
>
How about:
MatchQ[{1, 3, 2, 6, 5, 1, 4, 6, 3, 9},
Flatten[{BlankNullSequence[], {1, 4, 6}, BlankNullSequence[]}]]
True
?
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Pattern matching in lists Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-02-02 12:05 +0000
csiph-web