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

• To: mathgroup at smc.vnet.net
• Subject: [mg33179] Re: [mg33132] A rule with condition for the elements of a list
• From: Tomas Garza <tgarza01 at prodigy.net.mx>
• Date: Wed, 6 Mar 2002 01:56:34 -0500 (EST)
• References: <200203050808.DAA17066@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Some possibilities:

In:=
lst = {a, b, c*t, r*s, 2*t, 3, 0}
Out=
{a,b,c t,r s,2 t,3,0}

In:=
(# /. x_ :> If[FreeQ[x, t], t*x, x] & ) /@ lst
Out=
{a t,b t,c t,r s t,2 t,3 t,0}

In:=
(If[FreeQ[#, t], t*#, #] & ) /@ lst
Out=
{a t,b t,c t,r s t,2 t,3 t,0}

In:=
Cases[lst, x_ :> If[FreeQ[x, t], t*x, x]]
Out=
{a t,b t,c t,r s t,2 t,3 t,0}

Tomas Garza
Mexico City
----- Original Message -----
From: "Guillermo Sanchez" <guillerm at aida.usal.es>
To: mathgroup at smc.vnet.net
Subject: [mg33179] [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
>

```

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