using Distributions;
# Currently
[Distributions.tdistpdf, Distributions.tdistlogpdf, Distributions.tdistcdf]
# I want something like
Distributions.[tdistpdf, tdistlogpdf, tdistcdf]
wondering if there is an easy way to do this that I missed.
using Distributions;
# Currently
[Distributions.tdistpdf, Distributions.tdistlogpdf, Distributions.tdistcdf]
# I want something like
Distributions.[tdistpdf, tdistlogpdf, tdistcdf]
wondering if there is an easy way to do this that I missed.
Well, you could do:
using Distributions
const D = Distributions
[D.tdistpdf, D.tdistlogpdf, D.tdistcdf]
It looks like you’re trying to do this:
julia> import Distributions
julia> getproperty.(Ref(Distributions), [:tdistpdf, :tdistlogpdf, :tdistcdf])
3-element Array{Function,1}:
tdistpdf (generic function with 2 methods)
tdistlogpdf (generic function with 2 methods)
tdistcdf (generic function with 1 method)
But the const binding proposal seems much better.
Yea, I’ve been doing something like that
[pkg1.f1, pkg1.f2, pkg2.g1, pkg2.g1]
The title say to call multiple functions
, for that you can use metaprogramming
module A
boo() = println("1")
baz() = println("2")
bir() = println("3")
end
for f in [:boo, :baz, :bir]
@eval A.$f()
end
# Output
# 1
# 2
# 3