Re: Pure Functions in rules
- To: mathgroup at smc.vnet.net
- Subject: [mg16001] Re: [mg15932] Pure Functions in rules
- From: BobHanlon at aol.com
- Date: Fri, 19 Feb 1999 03:27:12 -0500
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 2/18/99 5:39:37 AM, wself at viking.emcmt.edu writes: >It appears that I cannot depend on using a pure function >in a pattern-matching rule. > >Here I am trying to convince reluctant students that they're >better off learning to use Mathematica than doing things >by hand, and we run across something like this, and in a >much more complicated situation where the trouble was >hard to isolate. > >I am quite frankly incensed by the behavior shown in >In/Out 80, below. Look at these examples: > [deleted examples] > >Now try this: > >In[80]:= {1,2,3}/.(m_List->(2*#& /@ m)) >Out[80]= {1,2,3} > Will, You need to use RuleDelayed vice Rule. {1,2,3}/.(m_List:>(2*#& /@ m)) {2,4,6} Bob Hanlon