Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: different results for Standard vs Prefix forms

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111449] Re: different results for Standard vs Prefix forms
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Mon, 2 Aug 2010 07:02:45 -0400 (EDT)

I don't think the O.P. had in mind asking for a fix. I think he was, in 
essence, trying to create a pure function with Block...

   f = Block[{n = 2}, #]&

... and then trying to evaluate that with argument Plot[n x, {x,1,2}]. 
He did this in one step, of course--the second of his two code lines.

The trouble, of course, is that the n in Block[{n = 2}, #]& is now 
localized to that Block, whereas the n in Plot[n x, {x,1,2}] is not 
localized in that Plot.

On 7/31/2010 2:39 AM, James Stein wrote:
> Block[{n = 2}, #&@Plot[n x, {x, 1, 2}]]
> Fixed that for you! (misplaced brackets)
>
> On Fri, Jul 30, 2010 at 3:55 AM, Yaroslav Bulatov<yaroslavvb at gmail.com>  wrote:
>> First one works, but second one doesn't, why?
>> Block[{n = 2}, Plot[n x, {x, 1, 2}]]
>> Block[{n = 2}, #]&@Plot[n x, {x, 1, 2}]
>>
>>
>

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: Mathematica- Use a previous equation into the function Function
  • Next by Date: Re: Mathematica- Use a previous equation into the function Function
  • Previous by thread: Re: Disable " symbol
  • Next by thread: Re: different results for Standard vs Prefix forms