« first day (857 days earlier)      last day (2388 days later) » 

12:03 AM
:-D
 
 
17 hours later…
5:00 PM
So far I often used anonymous functions (like f=@(x)(x-a)^2) for mathematical functions that serve as callback for other functions in my code. Is it better to define such functions using a function block?
I just did some testing and it seems that there is not much difference time wise.
 
 
2 hours later…
6:31 PM
@flawr I guess that if you use them often it's simply easier to define them as a separate function, so you don't have to copy the code every time.
 
7:01 PM
I don't see any reason not to use anonymous functions if you can. As you say, I don't think there's any performance advantage, only added functionality with a full function.
 
 
1 hour later…
8:24 PM
@Adriaan I often found myself having something like
for a=1:N;
 f=@(x)sin(v(a)*x);
y(a) = someFunction(f,and,some,other,arguments);
end
 
that's what anon functions/lambdas are for
depending on the number and length of and,some,other,arguments I'd be tempted to just put the definition of f inside the function call
 
ah in my context someFunction often is some general "solver" for a certain kind of problem, and f is basically just a parameter of that problem. (think for instance the RHS of a Poisson equation)
 
that's what I figured
and I'm not sure how that should affect the validity of my statements ;)
 
not at all, I just wanted to provide some context:)
Oh and they are very well suited for recursion obviously, that way we can get rid of all the evil for-loops.
 
well recursive lambdas are another matter :P
 
8:33 PM
oh you remind me of some challenge, I'll have to find it
 
Awww, babby flawr when he had to be told to self-answer
or she, 'cause you're a cowgirl by day
 
how dare you to assume I'm one of only two genders
 
fle?
 
found the challenge I was thinking of: codegolf.stackexchange.com/a/99669/24877
O_o
 

« first day (857 days earlier)      last day (2388 days later) »