# What's the "right" way to broadcast vector-valued functions?

**URL:** <https://discourse.julialang.org/t/whats-the-right-way-to-broadcast-vector-valued-functions/30232>\
**Category:** New to Julia\
**Tags:** broadcast, array\
**Created:** [October 23, 2019, 4:09pm UTC](https://discourse.julialang.org/t/whats-the-right-way-to-broadcast-vector-valued-functions/30232 "2019-10-23T16:09:43Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![jlchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlchan/32/10958_2.png) [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Post date:** [November 6, 2019, 4:15pm UTC](https://discourse.julialang.org/t/whats-the-right-way-to-broadcast-vector-valued-functions/30232/5 "2019-11-06T16:15:04Z")

</div>

Found a related question from 2018: [Destructuring and broadcast](https://discourse.julialang.org/t/destructuring-and-broadcast/5672). The motivation was similar (avoid storage and allocation of intermediate terms).

Adding broadcasting to tuple functions to Base is still [under development](https://github.com/JuliaLang/julia/issues/22129). In the meantime, I’ve found that [Destruct.jl](https://github.com/spalato/Destruct.jl) is fast and achieves what I’m looking for. The “unzip” function from [this StackExchange post](https://stackoverflow.com/questions/36367482/unzip-an-array-of-tuples-in-julia)

```julia
unzip(a) = map(x->getfield.(a, x), fieldnames(eltype(a)))
x = [1 2 3]
y = [2 3 4]
bar = (x,y)->(y,x)
f,g = unzip(bar.(x,y)) # usage

```

also seems pretty efficient.

---

_[View the full topic](https://discourse.julialang.org/t/whats-the-right-way-to-broadcast-vector-valued-functions/30232)._
