Quantcast

List functions defined from within current scope

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

List functions defined from within current scope

paul
As recently as 2008, Octave 3.0.2's "who" function accepted a "-functions"
option for listing user-defined functions:

http://www.network-theory.co.uk/docs/octave3/octave_66.html

I don't that command & option serves my aim of listing only functions that were
defined from within the current scope, as the option is no longer available in
Octave 3.6.2 and I can't test it.

Is there another way to list user-defined functions and/or functions defined
from within the current scope?

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: List functions defined from within current scope

Juan Pablo Carbajal-2
On Thu, Mar 7, 2013 at 2:12 AM, paul <[hidden email]> wrote:

> As recently as 2008, Octave 3.0.2's "who" function accepted a "-functions"
> option for listing user-defined functions:
>
> http://www.network-theory.co.uk/docs/octave3/octave_66.html
>
> I don't that command & option serves my aim of listing only functions that were
> defined from within the current scope, as the option is no longer available in
> Octave 3.6.2 and I can't test it.
>
> Is there another way to list user-defined functions and/or functions defined
> from within the current scope?
>
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave

functions defined in the command line are pretty much invisible.
octave:1> function f(); disp(1); end
octave:2> who
octave:3> whos

I wouldn't know why the function is not shown. Maybe it is just
something that got lost in the way?
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: List functions defined from within current scope

PetrSt
This post was updated on .
In reply to this post by paul
I suppose all user-defined functions should be present in the current workspace as function handles. If so, then "whos" returns structure with one of the fields "class". Comparing class field to string 'function_handle' should return the logical index matrix. It could look some like this:
wrks = whos;
mask = strcmp({wrks.class},'function_handle');
fun_names = wrks(mask).name

Doesn't work for the above example (i.e. comand line: function f(), disp(1); end), I have read after posting. I probably offered the solution you are not looking for.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: List functions defined from within current scope

Juan Pablo Carbajal-2
On Mon, Mar 18, 2013 at 11:31 AM, PetrSt <[hidden email]> wrote:

> I suppose all user-defined functions should be present in the current
> workspace as function handles. If so, then "whos" returns structure with one
> of the fields "class". Comparing class field to string 'function_handle'
> should return the logical index matrix. It could look some like this:
> wrks = whos;
> mask = strcmp({wrks.class},'function_handle');
> fun_names = wrks(mask).name
>
>
>
> --
> View this message in context: http://octave.1599824.n4.nabble.com/List-functions-defined-from-within-current-scope-tp4650574p4650914.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave

That doesn't seem to work here.
Do you have a working example?
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: List functions defined from within current scope

PetrSt
I didn't find any possibility to display functions created by function keyword, but if you know which functions should be created and you just want to check if they were, you can use exist('funname') command. In case of function defined from the command line it returns 103 and for function within m-file, invisible from command line otherwise, it returns 2 if checked from the current scope, e.g. during debug mode.
If you are producing unknown number of functions with unknown names than I'm not able to help.
Loading...