Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Rule confusion' topicStudent Support Forum > General > "Rule confusion"

Next Comment >Help | Reply To Topic
Author Comment/Response
David Glick
12/29/01 10:56am

The following rule replaces each member of the list with the number plus 1.

In[3]:=
list1={1,2,3,4};
list1/.{x_ ->x+1}

Out[4]=
{2,3,4,5}

Please let me know why next code does not replace each member of the list with the number 7

In[5]:=
list1/.{x_ ->7}

Out[5]=
7

How would I rewrite this rule to get each list member replaced by 7.
Thanks for your help
David Glick

Attachment: rule.nb, URL: ,

Subject (listing for 'Rule confusion')
Author Date Posted
Rule confusion David Glick 12/29/01 10:56am
Re: Rule confusion Forum Modera... 01/01/02 12:42pm
Next Comment >Help | Reply To Topic