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


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

Re: Pattern matching in lists

Started byAndrzej Kozlowski <akoz@mimuw.edu.pl>
First post2011-02-02 12:05 +0000
Last post2011-02-02 12:05 +0000
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Pattern matching in lists Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-02-02 12:05 +0000

#15803 — Re: Pattern matching in lists

FromAndrzej Kozlowski <akoz@mimuw.edu.pl>
Date2011-02-02 12:05 +0000
SubjectRe: Pattern matching in lists
Message-ID<iibhai$ooq$1@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

?



[toc] | [standalone]


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


csiph-web