MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

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


  • Prev by Date: piechart with percent...
  • Next by Date: Re: Install problem of Mathematica kernel
  • Previous by thread: Re: piechart with percent...
  • Next by thread: Re: Pattern matching / subsequence matching, question on