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)


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