|
|
|
Re: Anonymous Math Functions in IDL like Matlab [message #75371 is a reply to message #75310] |
Thu, 03 March 2011 15:13  |
rtk
Messages: 22 Registered: September 2008
|
Junior Member |
|
|
I wrote a bunch of higher-order function stuff for IDL awhile back and
included a hack that simulated a lambda function. Basically, it
defined the function on the fly and returned a string with the actual
name. You then used this with the higher-order function (or any
function). So, for your example,
square = lambda('x:x^2')
but to use it directly:
ans = call_function(square, 4)
Outside the context of a higher-order function, this isn't really that
useful. Still, if you want the code, I'll send it, just email me
"oneelkruns" "hotmail" "com". The higher-order functions were DLMs
for Linux and Windows, 32-bit only.
Also, you can define a procedure/function in IDL from the command
line. No need to quit and type a new file:
IDL> .run
- function square, x
- return, x*x
- end
% Compiled module: SQUARE.
IDL> print, square(4)
Perhaps what you are really looking for?
Ron
|
|
|