Re: Extracting information from lists
- To: mathgroup at smc.vnet.net
- Subject: [mg63425] Re: Extracting information from lists
- From: "Borut Levart" <BoLe79 at gmail.com>
- Date: Sat, 31 Dec 2005 06:40:23 -0500 (EST)
- References: <dojefh$fmb$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Perhaps I don't fully comprehend your question, so I guess your problem
is to find the position of start of ALL the runs. So it could be a run
of 1's, or 3's, and you should be able to locate their starting
positions.
If that is so, I would do it like this:
whereRuns[l_] :=
Position[
Replace[
Split[l],
e_List?(Length[#] = 2 &) :> Prepend[Rest[e], xxx],
2] // Flatten,
xxx] // Flatten
The function locates the runs, it replaces their first element by xxx,
and returns the positions of that xxx's.
In:=
where[lst]
Out=
{6,10,16}
I didn't turn your 4th element, 6, into 1, as David Park did, so I
don't get the desired result, but I also think your question is not in
exact consistency with your result.
Bye,
Borut