RE: Rules

• To: mathgroup at smc.vnet.net
• Subject: [mg66405] RE: [mg66359] Rules
• From: "David Park" <djmp at earthlink.net>
• Date: Thu, 11 May 2006 02:16:34 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```MR,

There is no essential difference between the two. {rule1, rule2,...} simply
allows you to apply more than one rule to the list. But what you should
check is the difference between /. and //. (ReplaceAll and ReplaceRepeated).
And you should carefully check the notes for ReplaceAll in Help.

If AList has a value, then it will be evaluated before the rules are applied
and therefore the rules will be applied to the items in AList.

AList = {x, y, z};

AList /. x -> Sin[x]
{Sin[x], y, z}

If you write

rule1 = AList -> BList     giving
{x, y, z} -> BList

then

AList /. rule1
BList

but that would be a strange way of doing things.

Basically the question is whether you want to give AList a value or not. If
you want to use it symbolically in equations then it is better not to give
it a value with a Set or SetDelayed statement. Rather, use a rule to
substitute values when you are ready.

Clear[AList]
AListRule = AList -> {x,y,z}

AList.{1, 2, 3};
% /. AListRule
x + 2 y + 3 z

David Park

David Park

From: Marcin Rak [mailto:umrakmm at cc.umanitoba.ca]
To: mathgroup at smc.vnet.net

Hey everyone,

I had two simple questions, and was wondering wether anyone could through
something my way:

1) When we have a list, call it AList, and we type the following
AList /. {rule1}
AList /. rule1
what is the difference between the two?  And, how would I go about
defining a rule for the variable AList, and a rule for the contents of the
list - obviously these are two different concepts, yet how would you
differentiate b/w the two?

Thanx to all
MR

```

• Prev by Date: Re: Rules
• Next by Date: Re: Extract any diagonal from a square matrix...
• Previous by thread: Re: Rules
• Next by thread: Creating a new table using values from a column in another table,