Re: Re: Mathematica 6.0 easier for me ... (small review)

*To*: mathgroup at smc.vnet.net*Subject*: [mg76639] Re: [mg76556] Re: [mg76457] Mathematica 6.0 easier for me ... (small review)*From*: DrMajorBob <drmajorbob at bigfoot.com>*Date*: Fri, 25 May 2007 06:28:21 -0400 (EDT)*References*: <200705230859.EAA23180@smc.vnet.net> <2889719.1180010222826.JavaMail.root@m35>*Reply-to*: drmajorbob at bigfoot.com

Twenty minutes search of the documentation yields no clue what $1 and $2 are about. Care to share the secret? Bobby On Thu, 24 May 2007 04:53:53 -0500, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote: > > On 23 May 2007, at 17:59, Paul at desinc.com wrote: > >> If I have >> lis={{1,10},{2,10},...{9,10},{11,20},{12,20}...{19,20} >> >> How do I use functional and/or rule to determine where the second >> number (lis[[i,2]]) jumped from 10 to 20 to 30 and save the pair. >> Assuming there was noise, I only want to store the first 10->20, then >> look for 20->30 and so on. So in time, I want my search to change as >> I progress through the list. Any input appreciated! > > I am not quite sure if I really understand what you wish to do. But > if what I think is correct, then it seems easy to do it using rule > based programming: > > FirstJump[lis_, n_, m_] := Flatten[({ > lis} /. {___, {x_, n}, {y_, m}, ___} :> Position[lis, {x, n}])] > > For example: > > > ls={{1,10},{2,10},{9,10},{11,20},{12,20},{19,20},{20,30}}; > > > FirstJump[ls,10,20] > > {3} > > > FirstJump[ls,20,30] > > {6} > > The above assumes that all the pairs in your list are distinct. If > they are not, then something more complicated is needed, e.g.: > > Clear[FirstJump] > > FirstJump[lis_, n_, m_] := Position[Flatten[({lis} /. {a___, {x_, n}, { > y_, m}, b___} :> {a, $1, $2, b}), 1], $1, 1] > > ls = {{1,10}, {2, 10}, {9, 10}, {9, 10}, {11, 20}, {12, 20}, {19, > 20}, {20, 30}}; > > > FirstJump[ls, 10, 20] > > {{4}} > > > Andrzej Kozlowski > > -- DrMajorBob at bigfoot.com

**References**:**Mathematica 6.0 easier for me ... (small review)***From:*Paul@desinc.com