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[]?


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[]?