# How to broadcast over only certain function arguments?

**URL:** <https://discourse.julialang.org/t/how-to-broadcast-over-only-certain-function-arguments/19274>\
**Category:** General Usage\
**Tags:** question, broadcast\
**Created:** [January 4, 2019, 4:09pm UTC](https://discourse.julialang.org/t/how-to-broadcast-over-only-certain-function-arguments/19274 "2019-01-04T16:09:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [January 4, 2019, 4:27pm UTC](https://discourse.julialang.org/t/how-to-broadcast-over-only-certain-function-arguments/19274/2 "2019-01-04T16:27:03Z")

</div>

You can turn one of the arguments into a tuple to consider it as a scalar:

For example (if I understood your question correctly):

```julia
f(x,y) = sum(x) + y
f([1,2,3], 4) #-> 10
f([1,2,3], 5) #-> 11

f.([1,2,3], [4,5]) # -> error

f.(([1,2,3],), [4,5]) # -> [10, 11]
                      # this works because ([1,2,3],) is now considered
                      # to be scalar and is broadcasted

```

Note how in the second case, the array argument `[1,2,3]` has been turned into a 1-element tuple containing the actual array argument: `([1,2,3],)`

It would also have been possible to use `Ref([1,2,3])` to achieve the same effect:

```julia
f.(Ref([1,2,3]), [4,5]) #-> [10, 11]

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-broadcast-over-only-certain-function-arguments/19274)._
