« first day (2185 days earlier)      last day (1027 days later) » 

12:09 PM
1
Q: Why are predefined variables not shown with their value in function handles?

Matt MajicIn MATLAB R2020b I have the following code: f=@(x) x.^2; y=2; g=@(x) f.*y and the output is g = function_handle with value: @(x)f.*y But y = 2, so I would expect the output to be @(x)f.*2. Is this how its supposed to work or a bug? And can I display it as f.*2 rather than f.*y?

This is actually a well-written, interesting question! And I couldn't even find a duplicate, nor answer.
 
I think this has to do with closures. When you define an anon function it stores away y at the time of definition, but it still refers to it by name. There was the "monster lamdbified function" question I answered a long while back, and it had all these named parameters inside.
 
12:51 PM
I think one time it was relatively inconsistent between matlab and octave
 
 
2 hours later…
3:11 PM
It makes sense that a closed variable that's a 5000-sized matrix will not be substituted
 
3:29 PM
Indeed, a lazy copy is the better approach.
 
Good point, lazy copying
 
Though my goal is to get OP to not use the ridiculous recursive anonymous function declaration. "It's anonymous functions all the way down!"
 
We should do that in a loop and see what the limit is :-D
 
3:47 PM
I have only glanced over this "Collectives" thing, but it doesn't sound like a good idea to me. Will it have the same "success" as SO Documentation?
 
3:58 PM
And this summarizes why I don't like it
 
> How is this different from the Documentation project?

> Good question... We’ve done quite a bit of research on what went wrong with the Documentation project. At the time, we didn't have the resources to fully support Documentation, but the research done then, and more recently around this project, has consistently validated an appetite for content beyond Q&A on Stack Overflow.

A second concern around Documentation was around the content quality. We feel that initially limiting posting of Articles to a small subset of users and expanding that later on to a bigger group through an approv
 
4:16 PM
I don't really understand what it does or what gap it is supposed to fill. But I suspect it's a revenue thing.
 
 
2 hours later…
5:55 PM
@CrisLuengo yes
With new ownership everything will be a revenue thing. The new owners paid a shitton of money, they wouldn't have done that to just have a knowledge base that was there anyway.
 
D: you don't believe they spent the money out of pure idealism?
@CrisLuengo so just hypothetically what kind of cake would you make?
 
 
3 hours later…
9:02 PM
@flawr No, I mean I would come work for you so I could help you select candidates based on their baking. I'm much better at tasting cake than making cake. :)
 

« first day (2185 days earlier)      last day (1027 days later) »