MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Pure Functions in rules

  • To: mathgroup at
  • Subject: [mg16001] Re: [mg15932] Pure Functions in rules
  • From: BobHanlon at
  • Date: Fri, 19 Feb 1999 03:27:12 -0500
  • Sender: owner-wri-mathgroup at

In a message dated 2/18/99 5:39:37 AM, wself at 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}


You need to use RuleDelayed vice Rule.

{1,2,3}/.(m_List:>(2*#& /@ m))


Bob Hanlon

  • Prev by Date: Re: implementing a stack
  • Next by Date: Re: MyPrependTo
  • Previous by thread: Pure Functions in rules
  • Next by thread: Re: Pure Functions in rules