Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

Re: What is a good way of returning a function from a Module[]?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83391] Re: [mg83287] What is a good way of returning a function from a Module[]?
  • From: "Szabolcs HorvÃt" <szhorvat at gmail.com>
  • Date: Mon, 19 Nov 2007 06:15:01 -0500 (EST)
  • References: <27565761.1195340077377.JavaMail.root@m35>

On Nov 18, 2007 8:49 PM, DrMajorBob <drmajorbob at bigfoot.com> wrote:
> Module[{a, b}, a = 1; b = a + 1; Function[{c}, Evaluate[a + b + c]]]
>
> Function[{c$}, 3 + c$]
>

Thank you for the replies, Peter and Bobby!

I stayed away from Evaluate[] because it only works on the outermost
level, i.e. Function[{c}, Evaluate[a] + Evaluate[b] + c] will not
work.  In some cases it is not possible to evaluate the complete body
of a function.

Here is a somewhat artificial example:

Module[{a, b}, a = 1; b = a + 1; Function[{x}, a + b + # & /@ x]]

Szabolcs


  • Prev by Date: addons in Mathematica 6???
  • Next by Date: GLToolbox - OpenGL 3D Graphics Package for Mathematica
  • Previous by thread: Re: What is a good way of returning a function from a Module[]?
  • Next by thread: Re: What is a good way of returning a function from a Module[]?