[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Are functional objects (functors/closures) possible?
From: |
Paul Kienzle |
Subject: |
Re: Are functional objects (functors/closures) possible? |
Date: |
Fri, 22 Nov 2002 12:55:54 -0500 |
User-agent: |
Mutt/1.2.5.1i |
Hmmm....
maybe you could fake a curry using a DLD function. You could
call it something like:
f = curry('x','y','g(x,y,$a,$b)')
which would do the equivalent of the following:
static n = 0;
global curry_val;
s.a = a;
s.b = b;
curry_val{n} = s;
eval(sprintf("function curry_ret = curry%d(x,y)\n\
s=curry_val{%d};\n\
curry_ret=g(x,y,s.a,s.b);\n\
endfunction",n,n);
n++;
This is a little cleaner if curry were a text function:
f = curry x y "g(x,y,$a,$b)"
but right now you cannot tag a function as a text function
unless it is a built-in.
Paul Kienzle
address@hidden
On Fri, Nov 22, 2002 at 11:07:52AM -0600, John W. Eaton wrote:
> On 21-Nov-2002, Brett Viren <address@hidden> wrote:
>
> | I am using Octave 2.1.36 for the "lsode" ODE solver. The ODE I want
> | to solve is a function of many parameters. Is there some way to pass
> | in these parameters to the function to be used durring the "lsode"
> | running?
> |
> | The only thing I can think of is to use globals.
>
> To me, that seems to be a reasonable way to solve this problem. If
> many global variables bother you, you can pack all the data in a
> structure or cell array (in recent snapshot versions of Octave, at
> least).
>
> | If octave supported functional objects, (aka functors, aka closures,
> | aka currying) then I could create an instance of "f" which stores the
> | values of its parameters. Searching google and the ML archives I
> | didn't find anything.
>
> Right, Octave does not support this.
>
> | If octave doesn't support this directly, is there a way to use C++
> | functional objects (ie, objects with an operator()()) through writing
> | a dynamically loaded .oct file?
>
> Sorry, I'm not following what you want. Can you be more specific
> about what it is you want and how it would help you?
>
> jwe
>
>
>
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web: http://www.octave.org
> How to fund new projects: http://www.octave.org/funding.html
> Subscription information: http://www.octave.org/archive.html
> -------------------------------------------------------------
>
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------