Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

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


  • Prev by Date: Re: Retaining variable/function expressions from session to session
  • Next by Date: Re: Retaining variable/function expressions from session to session
  • Previous by thread: Re: Extracting information from lists
  • Next by thread: Re: does this shut down anyone else's kernel?