# An easy way to call multiple functions from a package?

**URL:** <https://discourse.julialang.org/t/an-easy-way-to-call-multiple-functions-from-a-package/49383>\
**Category:** New to Julia\
**Created:** [October 31, 2020, 8:10pm UTC](https://discourse.julialang.org/t/an-easy-way-to-call-multiple-functions-from-a-package/49383 "2020-10-31T20:10:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Albert\_Zevelev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albert_zevelev/32/11844_2.png) [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Post date:** [October 31, 2020, 8:10pm UTC](https://discourse.julialang.org/t/an-easy-way-to-call-multiple-functions-from-a-package/49383/1 "2020-10-31T20:10:05Z")

</div>

```julia
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.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [October 31, 2020, 8:20pm UTC](https://discourse.julialang.org/t/an-easy-way-to-call-multiple-functions-from-a-package/49383/2 "2020-10-31T20:20:45Z")

</div>

Well, you could do:

```julia
using Distributions
const D = Distributions

[D.tdistpdf, D.tdistlogpdf, D.tdistcdf]

```

---

<div class="post-metadata">

**Author:** ![johnmyleswhite](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnmyleswhite/32/31_2.png) [@johnmyleswhite](https://discourse.julialang.org/u/johnmyleswhite)\
**Post date:** [October 31, 2020, 8:36pm UTC](https://discourse.julialang.org/t/an-easy-way-to-call-multiple-functions-from-a-package/49383/3 "2020-10-31T20:36:15Z")

</div>

It looks like you’re trying to do this:

```julia
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.

---

<div class="post-metadata">

**Author:** ![Albert\_Zevelev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albert_zevelev/32/11844_2.png) [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Post date:** [October 31, 2020, 8:40pm UTC](https://discourse.julialang.org/t/an-easy-way-to-call-multiple-functions-from-a-package/49383/4 "2020-10-31T20:40:13Z")

</div>

Yea, I’ve been doing something like that

```julia
[pkg1.f1, pkg1.f2, pkg2.g1, pkg2.g1]

```

---

<div class="post-metadata">

**Author:** ![josePereiro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josepereiro/32/17322_2.png) [@josePereiro](https://discourse.julialang.org/u/josePereiro)\
**Post date:** [November 1, 2020, 8:22pm UTC](https://discourse.julialang.org/t/an-easy-way-to-call-multiple-functions-from-a-package/49383/5 "2020-11-01T20:22:23Z")

</div>

The title say `to call multiple functions`, for that you can use metaprogramming

```julia
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

```
