Broadcasting across a nested array

Try wrapping the first operand in a Ref to help Julia understand it is a “scalar”:

julia> Ref([10, 100]) .+ [[5, 5], [6, 6], [7, 7]]
 3-element Array{Array{Int64,1},1}:
  [15, 105]
  [16, 106]
  [17, 107]


This discussion contains a lot more details:

including some alternative ways of doing this, for example turning the “scalar” argument to a 1-Tuple:

julia> ([10, 100],) .+ [[5, 5], [6, 6], [7, 7]]
3-element Array{Array{Int64,1},1}:
 [15, 105]
 [16, 106]
 [17, 107]
4 Likes