MathGroup Archive 2005

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

Search the Archive

Re: rules and lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54250] Re: rules and lists
  • From: "Ingolf Dahl" <ingolf.dahl at telia.com>
  • Date: Mon, 14 Feb 2005 21:50:44 -0500 (EST)
  • Reply-to: <ingolf.dahl at telia.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Here is one way: use an intermediate variable z, and do it in two steps:

({1, 2, 3, 3, 1, 2} //. {{x___, 1, 2, y___} -> {x, z, y}}) //. 
{{x___, z, y___} -> {x, Sequence[1, 2, 3], y}}

Ingolf Dahl
ingolf.dahl at telia.com
Sweden

-----Original Message-----
From: Erich Neuwirth [mailto:erich.neuwirth at univie.ac.at] 
To: mathgroup at smc.vnet.net
Subject: [mg54250]  rules and lists

I would like to replace sublists of a list to be replaced by another 
list, such that for example the rule
{1,2}->{1,2,3}
wout tranform
{1,2,3,3,1,2} into
{1,2,3,3,3,1,2,3}
Simply gibbin the transformation rule in the form
{x___,1,2,y___}->{x,1,2,3,y}
does not work.
What is the idiom to do what I want?




  • Prev by Date: solve doesn't solve
  • Next by Date: Re: Using Select with arrays? (Relative newbie)
  • Previous by thread: Re: rules and lists
  • Next by thread: Re: rules and lists