MathGroup Archive 2006

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

Search the Archive

Re: Repeated sequence

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63991] Re: Repeated sequence
  • From: "Ray Koopman" <koopman at sfu.ca>
  • Date: Thu, 26 Jan 2006 03:43:37 -0500 (EST)
  • References: <dr80a3$ph3$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Borut Levart wrote:
> Dear users,
>
> I have a list of DXF Polylines data, and I would like to extract the
> coordinates {x,y}_i out of each sublist (code 10 followed by x1, 20 by
> y1, and again 10 by x2, and so forth), but the length of the 10-20 run
> is general. I've read about Repeated pattern, but still can't extract
> the whole run.
> I would like to solve this with patterns.
>
> list={{5,8 B,330,F,100,AcDbEntity,8,0,100,AcDbPolyline,90,2,70,0,43,0.,
>     10,12.1426,20,18.2932,10,10.3823,20,15.2443,0},{5,8 F,330,F,
>     100,AcDbEntity,8,0,100,AcDbPolyline,90,2,70,0,43,0.,10,
>     10.3823,20,15.2443,10,8.62206,20,12.1954,0},{
>   5,92,330,F,100,AcDbEntity,8,0,100,AcDbPolyline,90,2,70,0,43,0.,
>     10,8.62206,20,12.1954,10,12.1426,20,12.1954,0},{5,
>     93,330,F,100,AcDbEntity,8,0,100,AcDbPolyline,90,2,70,0,43,0.,
>     10,12.1426,20,12.1954,10,15.6631,20,12.1954,0},{5,
>   94,330,F,100,AcDbEntity,8,0,100,AcDbPolyline,90,2,70,0,43,0.,
>     10,15.6631,20,12.1954,10,13.9028,20,15.2443,0},{5,
>     95,330,F,100,AcDbEntity,8,0,100,AcDbPolyline,90,2,70,0,43,0.,
>     10,13.9028,20,15.2443,10,12.1426,20,18.2932,0},{5,
>   B9,330,F,100,AcDbEntity,8,0,100,AcDbPolyline,90,14,70,0,43,0.,
>     10,3.7764,20,18.0222,10,6.87499,20,17.7511,10,3.42781,20,16.6671,
>     10,6.10034,20,16.0477,10,4.70598,20,15.5831,10,5.51936,20,15.0798,
>     10,4.47358,20,14.5377,
>
> 10,5.44189,20,13.686,10,4.62851,20,12.7181,10,5.44189,20,11.3631,10,
>     4.35739,20,10.0467,10,4.82217,20,9.0014,10,4.20246,20,
>     7.33662,10,5.79048,20,6.83332,0}}

Cases[Partition[#,4,1],{10,_,20,_}][[All,{2,4}]]& /@ list

{{{12.1426,18.2932},{10.3823,15.2443}},
 {{10.3823,15.2443},{8.62206,12.1954}},
 {{8.62206,12.1954},{12.1426,12.1954}},
 {{12.1426,12.1954},{15.6631,12.1954}},
 {{15.6631,12.1954},{13.9028,15.2443}},
 {{13.9028,15.2443},{12.1426,18.2932}},
 {{3.7764,18.0222},{6.87499,17.7511},
  {3.42781,16.6671},{6.10034,16.0477},
  {4.70598,15.5831},{5.51936,15.0798},
  {4.47358,14.5377},{5.44189,13.686},
  {4.62851,12.7181},{5.44189,11.3631},
  {4.35739,10.0467},{4.82217,9.0014},
  {4.20246,7.33662},{5.79048,6.83332}}}


  • Prev by Date: Re: Repeated sequence
  • Next by Date: Re: Assuming to be a real number is useless even in simple cases?
  • Previous by thread: Re: Repeated sequence
  • Next by thread: Re: Repeated sequence