# Element-wise product of vector of vectors

**URL:** <https://discourse.julialang.org/t/element-wise-product-of-vector-of-vectors/28250>\
**Category:** New to Julia\
**Tags:** broadcast\
**Created:** [August 31, 2019, 11:50pm UTC](https://discourse.julialang.org/t/element-wise-product-of-vector-of-vectors/28250 "2019-08-31T23:50:45Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [September 1, 2019, 5:26am UTC](https://discourse.julialang.org/t/element-wise-product-of-vector-of-vectors/28250/5 "2019-09-01T05:26:35Z")

</div>

> [@baptiste](#):
>
> equivalent to the for loop

You can, in principle, write loops to do this without allocations (if the destination is already allocated) but with nested broadcast, I think it is trickier.

> [@baptiste](#):
>
> with a binary infix operator syntax

Here is one way to do it:

```julia
julia> let ⋆(x, y) = x .* y
           [[1], [2, 3]] .⋆ [[4], [5]]
       end
2-element Array{Array{Int64,1},1}:
 [4]
 [10, 15]

```

You can also define `⋆(x, y)` globally if you need to use it everywhere.

See also: [Idiomatic way to write element-wise combination of array of arrays?](https://discourse.julialang.org/t/idiomatic-way-to-write-element-wise-combination-of-array-of-arrays/18467)

---

_[View the full topic](https://discourse.julialang.org/t/element-wise-product-of-vector-of-vectors/28250)._
