Nested Functions alternative?

Jason Carver ynj0qeh02 at sneakemail.com
Sun Jun 21 15:18:18 CDT 2009


Since Octave doesn't support nested functions, is there a suggested
alternative for closures of non-trivial method size?
For example, I want to do something like this:

function f = sophisticated_func_many_args(arg2,arg3,arg4)
  function ans = sophisticated_func_one_arg(arg1)
    #do something with args 1-4 for several lines
    #set answer
  end
  f = @sophisticated_func_one_arg
end

one_arg_func = sophisticated_func_many_args(2,3,4)
result = built_in_library_call(one_arg_func)

This situation is particularly relevant when a library requires a
single-argument function passed in (eg~ ode45).  Maybe I'm just spoiled with
python lately, but I don't even see the imperative workaround for this
anymore.  What is the suggested alternative for this pattern in Octave?

Cheers,
Carver

Slique.com - builds group memory by putting all your group's email, files
and documents in one place
I'm trying this out: http://five.sentenc.es/ (sans code, of course)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www-old.cae.wisc.edu/pipermail/help-octave/attachments/20090621/25bab9f1/attachment.html 


More information about the Help-octave mailing list