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

• To: mathgroup at smc.vnet.net
• Subject: [mg33162] Re: [mg33132] A rule with condition for the elements of a list
• From: BobHanlon at aol.com
• Date: Wed, 6 Mar 2002 01:55:42 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```In a message dated 3/5/02 4:13:17 AM, guillerm at aida.usal.es writes:

>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]
>

lst={a,b,c*t,r*s,2*t,3,0};

lst /. c_?(FreeQ[#,t,1]&) -> c*t /. t^2->t

{a*t, b*t, c*t, r*s*t, 2*t, 3*t, 0}

or

lst*t /. t^2->t

{a*t, b*t, c*t, r*s*t, 2*t, 3*t, 0}

Bob Hanlon
Chantilly, VA  USA

```

• Prev by Date: RE: Machine-size real number?
• Next by Date: Re: kernel running programs
• Previous by thread: RE: A rule with condition for the elements of a list
• Next by thread: RE: A rule with condition for the elements of a list