Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: Pure Functions in rules

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16003] Re: Pure Functions in rules
  • From: tburton at brahea.com (Tom Burton)
  • Date: Fri, 19 Feb 1999 03:27:14 -0500
  • Organization: Brahea, Inc.
  • References: <7ag34l$aie@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Will,

Suggest using delayed evaluation (:>) of rule's RHS when that RHS
depends on a symbol (m here) introduced on the LHS.

Don't blame pure functions; blame Map. Any function mapped onto an
undefined symbol returns that symbol. When you use "->" instead of ":>".
you allow the function to operate before m is defined. That's why you
get "{1,2,3}". 

Tom

In[208]:= {1, 2, 3} /. m_List :> (2*#1 & ) /@ m
Out[208]= {2, 4, 6}

On 17 Feb 1999 22:58:13 -0500, in comp.soft-sys.math.mathematica you
wrote:

>It appears that I cannot depend on using a pure function
>in a pattern-matching rule.
>...
>
>In[79]:=     {1,2,3}/.m_List->f[m]
>Out[79]=    {2,4,6}
>
>Now try this:
>
>In[80]:=     {1,2,3}/.(m_List->(2*#& /@ m))
>Out[80]=    {1,2,3}
>
>Does anyone (say, at WRI for example) care to comment on
>this?
>
>Will Self

Tom Burton


  • Prev by Date: Re: Plot[] problem (plnr) - help !!!
  • Next by Date: Strange result of Limit function in Mathematica3.0
  • Previous by thread: Re: Pure Functions in rules
  • Next by thread: Re: Pure Functions in rules