Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Re: Re: Re: finding the position of a pattern in list (Correction)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64724] Re: [mg64660] Re: [mg64619] Re: Re: [mg64583] finding the position of a pattern in list (Correction)
  • From: ggroup at sarj.ca
  • Date: Wed, 1 Mar 2006 04:11:42 -0500 (EST)
  • References: <200602240518.AAA17528@smc.vnet.net> <C187B55A-4417-481E-A6E7-394BCE24F6E5@mimuw.edu.pl> <200602250753.CAA13989@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On Sat, 25 Feb 2006 02:53:21 -0500 (EST), Carl K. Woll wrote

<snip> 

> Thanks for advocating my "method" while I've been attending another 
> matter. There's been a new addition to my family, and I've been 
> enjoying that.

Congratulations!

> Concerning your implementation, I would construct the sparse array 
> differently, avoiding ListConvolve:

I'm trying to understand what this method is doing:

> pos5[li_] := Module[{m, r},
>    m = Most[li];
>    r = Rest[li];
>    SparseArray[(r - m)r] /. SparseArray[_,_,_,p_]:>Flatten[p[[2,2]]]
> ]
<snip>

If I understand correctly, the basic method is:
1. Construct a list "(r-m)r" which has the value 1 anywhere 
   that there is a 0->1 transition, and zero everywhere else.
2. Create a SparseArray, which will effectively extract the positions of the
   elements = 1.
3. Extract this positional information using pattern matching.

What isn't clear to me from the documentation is; what is the structure of the 
data stored in the pattern p?  In other words, how would you know that you 
want element p[[2,2]] as opposed to some other element of p?

Thanks!


  • Prev by Date: Re: Q: How do I format text within a cell of GridBox[]?
  • Next by Date: Re: pictures of mathematics on a non-white background
  • Previous by thread: Re: Q: How do I format text within a cell of GridBox[]?
  • Next by thread: Re: pictures of mathematics on a non-white background