« first day (2304 days earlier)      last day (929 days later) » 

11:45 AM
@Feeds I don't get it, Cleve...
 
didn't he just recently make a similar post?
 
yes, it's linked at the top
 
 
3 hours later…
3:16 PM
No idea what that graphix function used in his posts is
 
 
2 hours later…
5:23 PM
> Wenjian Yu about 17 hours ago
This is interesting. Would you please share the source codes to explain how it works? Thank you!

Cleve Moler about 16 hours ago
Yes, I intend to supply the source code and a more complete explanation. -- Cleve
@LuisMendo ^that is probably relevant, comments on the teapot post
 
5:41 PM
Ah, good catch. Yes, posting code which uses unknown functions is not very useful...
 
@LuisMendo Nice writeup regarding the nargout stuff! There were many things I wasn't aware of.
 
Thanks! I wasn't aware of (or remember) some of them, either. But the question prompted me to a bit of searching...
 
I just started opening the documentation when your answer popped up
 
Every now and then an interesting question shows up :-)
 
I just noticed: I don't think you actually answered op's question
 
5:44 PM
D:
 
"No."
actually with some eval it might work
 
There are two questions. I answer the first :-) The second could be done by some ugly try-catching but bah
 
but it's not gonna be pretty
 
Exactly
Well, maybe you can add a second answer? Not pretty solution, but probably interesting as a sort of hack
 
challenge accepted:)
 
5:47 PM
Haha
I was thinking: a loop with calls with increasing number of outputs until one fails (with try ... catch)
What's your eval idea?
 
For some reason there is a fun2str method
so I thought one could try to find the name of function that was called inside the anonymous function
and if it is another anonymous function we could recurse
@LuisMendo what if the function does not terminate for all numbers of output arguments that are divisible by 3? :D
 
@flawr Ah. But that parsing can be tricky. For example, @(x) 1./(2+find(x))
 
does that work with multiple outputs?
 
@flawr Heh. Good point. Bot a good idea calling a function repeatedly. Also, you don't know which inputs are acceptable
 
i would have expected that if you have an expression that is not just a function call after the @(...) we only have one output argument anyway
 
5:53 PM
@flawr You are right, it doesn't. Not sure it that makes it easier of more difficult
@flawr That looks sensible, yes
 
my idea was if it is of the form @(...)some_fun(....) then we can check some_fun, otherwise it would just be one output arg
hm I'd also have to account for curried functions. (like f=@(x)@(y)...)
actually no, I can just remove all the @(...)
 
This is beginning to get difficult
 
6:14 PM
dang
a function could contain an eval statement
 
6:29 PM
ok let's assume it does not
how can I find whether some function name (as a string) fun is the name of a named function or a variable that contains an anonymous function?
 
Hold on, are you trying to distinguish those two cases, or either works?
you might be able to do something with functions()
probably needs some exception handling because you can eval an anon function's varname but you can't eval the name of a named function
 
Use functions:
 
functions(eval(name)) -> if errors, try functions(eval(['@' name]))
 
>> f =  @(x) find(x);
>> functions(f)
ans =
  struct with fields:

            function: '@(x)find(x)'
                type: 'anonymous'
                file: ''
           workspace: {[1×1 struct]}
    within_file_path: '__base_function'
>> f = @find;
>> functions(f)
ans =
  struct with fields:

    function: 'find'
        type: 'simple'
        file: ''
Ah, didn't see you already suggested that, @Andras
 
great minds think alike!
 
6:36 PM
Hehe
 
yeah I got a similar solution
I have a hunch I'm overthinking this: pastebin.com/ph8VVYdt
 
 
1 hour later…
8:19 PM
@flawr I couldn't follow all of the code, but do you really need func2str and eval? You can do nargout(fname) where fname is a vector with the name of a function
But only for named functions
 
8:57 PM
And all of this is moot really, as the number of output arguments could depend on the values of the inputs given. I can write a function that returns a different number of outputs depending on how it's called. And I can write a function that does different things depending on the number of outputs that are requested by the caller. I don't think there's a way to do what the OP wants, I think OP needs to rethink their code logic if it depends on the number of output arguments to a function.
 
 
1 hour later…
10:00 PM
@LuisMendo right now I'm too tired to think, I'll have to think about it tomorrow:)
oh look who's a painter: luismendo.com
 
That's actually really good work!
Here I thought Luis was in Madrid, turns out he's in Tokyo... :p
 
10:53 PM
Yes, I've "bumped" into him online several times, trying to find citations or other stuff about me :-) Also, when I got into Twitter I wanted the acount name @luismendo, but he got there fist. I think he's from Salamanca (northwestern Spain)
@CrisLuengo Good point about timeit's second input. It's a nice illustration that the number of function outputs can't be predicted
 
if you know where he lives you can challenge him to a duel
2
 

« first day (2304 days earlier)      last day (929 days later) »