我如何在 julia 的模块中获取函数列表
how can i get function list in a module in julia
我想获取 julia 模块中的函数列表。
这是我的测试代码:
module m
function foo(x::Int)
s = 0
for i = 1:x
s += i/2
end
return s
end
end
for nm in names(m, all=true)
println(nm)
end
我明白了:
#eval
#foo
#include
eval
foo
include
m
它有一些我不知道的东西。
在 stackoverlow 中关于它的答案太旧并且不起作用。
如何在模块中获取我的函数列表,如果我获取了符号,我如何根据符号获取函数?
[x for x in names(m, all=true) if getproperty(m,x) isa Function && x ∉ (:eval, :include)]
我想获取 julia 模块中的函数列表。
这是我的测试代码:
module m
function foo(x::Int)
s = 0
for i = 1:x
s += i/2
end
return s
end
end
for nm in names(m, all=true)
println(nm)
end
我明白了:
#eval
#foo
#include
eval
foo
include
m
它有一些我不知道的东西。
在 stackoverlow 中关于它的答案太旧并且不起作用。
如何在模块中获取我的函数列表,如果我获取了符号,我如何根据符号获取函数?
[x for x in names(m, all=true) if getproperty(m,x) isa Function && x ∉ (:eval, :include)]