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

*To*: mathgroup at smc.vnet.net*Subject*: [mg76633] Re: [mg76556] Re: [mg76457] Mathematica 6.0 easier for me ... (small review)*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Fri, 25 May 2007 06:25:14 -0400 (EDT)*References*: <200705230859.EAA23180@smc.vnet.net> <2889719.1180010222826.JavaMail.root@m35> <op.tst6hjbkqu6oor@monster.ma.dl.cox.net>

They are just instances of the most sensational and undocumented new feature of Mathematica 6: mind reading. $1, $2 ... etc, stand for whatever the programmer has in mind when he writes his program and they keep their values even when the code is shared by e-mail. Of course an invention of this kind had to be kept strictly secret lest a total panic ensued (comparable to what happened after Orson Wells' famous broadcast of "War of the Worlds"), so naturally your 20 minutes spent on searching the documentation were a sheer waste of time. However, since only the original programmer knows what he had in mind, I hasten to explain. $1 (and the not really needed $2) stand for anything that is different from all other defined symbols in the current session. I used this new powerful and secret technology simply because I was just too much in a hurry to use obsolete old constructs like Block, Module, or Unique for what was not intended as serious code but only an illustration. As the OP did not really explain clearly what he wanted, I had to interpret his intentions myself, and my interpretation was that he was looking for specific "jumps" form one given value to another given value, and wanted to ignore any other possible jumps. Probably this interpretation was incorrect since all other posters seem to have assumed something different. Andrzej Kozlowski On 24 May 2007, at 23:57, DrMajorBob wrote: > 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