Is there a command in Julia 1.1 that lists all the methods that are available in a module?
e.g.
module MyMod
test1() = 1
test2() = 2
test3() = 3
end
Which would return:
[test1,test2,test3]
Is there a command in Julia 1.1 that lists all the methods that are available in a module?
e.g.
module MyMod
test1() = 1
test2() = 2
test3() = 3
end
Which would return:
[test1,test2,test3]
I find this
names(x::Module; all::Bool = false, imported::Bool = false)
Get an array of the names exported by a Module
, excluding deprecated names. If all
is true, then the list also includes non-exported names defined in the module, deprecated names, and compiler-generated names. If imported
is true, then names explicitly imported from other modules are also included.
As a special case, all names defined in Main
are considered “exported”, since it is not idiomatic to explicitly export names from Main
.
I get a 354-element vector. It is not completely shown on my console.
How can I get the long list complete.
show(stdout, "text/plain", somevector)
there is also the package TerminalPager which can be used like:
using TerminalPager
# [...]
somevector |> pager
I usually do foreach(println, x)
.
This is not the correct answer, because names() will export all names, not only those of the functions. How can I get only the names of the functions?
you could just filter all the names for beeing a function or not.
filter( x -> isa(getfield(module_name, x), Function), names(module_name))
# or
filter( x -> isa(getfield(module_name, x), Function), names(module_name; all=true))
Thanks! Now using:
function list_functions()
fncs = filter( x -> isa(getfield(Main, x), Function), names(Main))
for (i, fn) in pairs(fncs)
println(fn)
if (mod(i, 10)) == 0
println("Press enter to continue...")
readline()
end
end
end
Check also this alternative:
function list_functions(Module)
fncs = filter(x -> isa(getfield(Module, x), Function), names(Module))
foreach(x -> (println.(x); Base.prompt("\nENTER")), Iterators.partition(fncs, 10))
end