Re: Mathematica 6.0 easier for me ... (small review)
- To: mathgroup at smc.vnet.net
- Subject: [mg76581] Re: Mathematica 6.0 easier for me ... (small review)
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Thu, 24 May 2007 06:06:51 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <f30vpv$mkn$1@smc.vnet.net>
Paul at desinc.com wrote: [snip] > 4. At work, I haven't had to resort to other programs because > Mathematica wasn't the best choice. This is extremely nice. BTW, > There's a "temporal" advantage with procedural programming that hasn't > been apparant to me in functional or rule. Still working on it. Maybe > someone can help. 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! [snip] The following expression should be a good start: In[1]:= lst = {{1, 10}, {2, 10}, {3, 10}, {4, 10}, {8, 10}, {9, 10}, {11, 20}, {12, 20}, {13, 20}, {16, 20}, {17, 20}, {18, 20}, {25, 30}, {26, 30}, {27, 30}, {28, 30}, {29, 30}}; (First[Take[##1, -1]] & ) /@ Drop[Split[lst, Last[#1] == Last[#2] & ], -1] Out[2]= {{9, 10}, {18, 20}} Regards, Jean-Marc