MathGroup Archive 2002

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

Search the Archive

RE: A rule with condition for the elements of a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33157] RE: [mg33132] A rule with condition for the elements of a list
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Wed, 6 Mar 2002 01:55:33 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

> -----Original Message-----
> From: guillerm at aida.usal.es [mailto:guillerm at aida.usal.es]
To: mathgroup at smc.vnet.net
> Sent: Tuesday, March 05, 2002 9:09 AM
> To: mathgroup at smc.vnet.net
> Subject: [mg33157] [mg33132] A rule with condition for the elements of a list
> 
> 
> Given a list like this : 
>         
> lst = {a, b, c*t, r*s, 2*t, 3, 0};
> 
> I would like build a rule (c -> c t) for each elements c of the list
> that are not function of t  that give like solution :
> 
> Out[] := {a t, b t, c t, r s t, 2 t, 3 t, 0}
> 
> I have tested the following way but they are not work
> 
> lst /. (c_ /; FreeQ[c, t]) -> c*t
> 
> and 
> 
> integrate[c_, t_] := c t /; FreeQ[c, t]
> lst /. c_ -> integrate[c, t]
> 
> I will appreciate your held
> 
> Guillermo Sanchez
> 

Guillermo,

In[3]:= 
Replace[lst,c_ \[RuleDelayed]  c t /;FreeQ[c,t],{1}]
Out[3]=
{a t,b t,c t,r s t,2 t,3 t,0}

Replace[lst, rule, {1}] restricts replacement to the elements of lst (at
level 1). ReplaceAll definitely does too much.

--
Hartmut



  • Prev by Date: Re: How to transform x axis on ListPlot?
  • Next by Date: Re: A rule with condition for the elements of a list
  • Previous by thread: RE: A rule with condition for the elements of a list
  • Next by thread: Automatic sound recording