Re: Extracting information from lists
- To: mathgroup at smc.vnet.net
- Subject: [mg63353] Re: [mg63323] Extracting information from lists
- From: "Barthelet, Luc" <lucb at ea.com>
- Date: Sat, 24 Dec 2005 16:03:00 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
I suspect you already got many answers, but this is one more: First /@ Cases[ Transpose[{Most[FoldList[Plus, 1, Length[#] & /@ Split[list]]], Split[list]}] , {_, {x__}} /; x == 1] {3, 6, 10, 16} -----Original Message----- From: Tony King [mailto:mathstutoring at ntlworld.com] To: mathgroup at smc.vnet.net Subject: [mg63353] [mg63323] Extracting information from lists Does anyone know of a function that will allow me to extract the positions of the first elements of runs of similar elements within a list. For example, suppose that list={7,9,1,6,8,1,1,6,5,1,1,1,8,7,6,1,1,1,1,7} I need a function that will return {3,6,10,16} corresponding to the runs {1},{1,1},{1,1,1},{1,1,1,1} within list Many thanks Tony