Pattern matching / subsequence matching, question on example in
- To: mathgroup at smc.vnet.net
- Subject: [mg101419] Pattern matching / subsequence matching, question on example in
- From: heycarnut <heycarnut at gmail.com>
- Date: Tue, 7 Jul 2009 05:04:00 -0400 (EDT)
On pp 154-156 of the book, the example to search a sequence of digits
for a given subsequence is shown as
FindSubsequence[lis_List, subseq_List] := Module[{p}, p =
Partition[lis, Length[subseq], 1]; Position[p, Flatten[{___,subseq,
___}]]]
I'm puzzled at the use of Flatten[{___,subseq, ___}] for the pattern,
instead of just subseq, and can't seem to see what, if anything, it
adds to the functionality of the example. Can someone thaw my brain
freeze?
Thanks
Rob
- Follow-Ups:
- Re: Pattern matching / subsequence matching, question
- From: Daniel Lichtblau <danl@wolfram.com>
- Re: Pattern matching / subsequence matching, question on
- From: DrMajorBob <btreat1@austin.rr.com>
- Re: Pattern matching / subsequence matching, question