# Broadcasting across a nested array

**URL:** <https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700>\
**Category:** General Usage\
**Tags:** broadcasting\
**Created:** [March 10, 2019, 12:21pm UTC](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700 "2019-03-10T12:21:48Z")\
**Posts on this page:** 8\
**Page:** 3

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [March 13, 2019, 8:29pm UTC](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700/41 "2019-03-13T20:29:55Z")

</div>

> [@mbauman](#):
>
> I’m really quite confused as to why you’re so adamantly opposed to our current setup…

Stating the same reason again: it is confusing! See the discussion of `Array{Array{2}}` above for specific examples. I was lucky to catch a similar issue early in my code (when I changed `a .+ b` to `a ./ b`) because inner arrays were 1D instead of 2D in my case and thus the resulting type became wrong.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [March 13, 2019, 8:45pm UTC](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700/42 "2019-03-13T20:45:41Z")

</div>

I really do encourage you to keep working with Julia and give this concept some time to settle. I know personally, dot-broadcasting has changed how I think about programs. I _know_ in Julia that `f(x)` is going to operate directly on `x` — and not its elements. Pretty much universally. And that’s a really awesome expressive power.

> **technicalities**
>
> Just for what it’s worth, there’s a technical reason why we can’t completely hide this functionality behind `using LinearAlgebra`: The method table for `+` is global and shared across every single package/module. And we want to enable linear algebra semantics on all `AbstractArray` subtypes (including `Array`). So even if we “buried” this behavior into the `LinearAlgebra` package and didn’t automatically bundle it with a base install of Julia, the moment any other package wrote `using LinearAlgebra` you’d get these behaviors everywhere. Thus, in this case, it’s more consistent to just have these behaviors built in to Julia from the get-go.

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [March 13, 2019, 8:48pm UTC](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700/43 "2019-03-13T20:48:46Z")

</div>

Ok, I get it, 2d-arrays-are-matrices-by-default won’t go anywhere 🙂 Just wanted to help future new users, at least hope they will stumble on this thread before encountering problems.

---

<div class="post-metadata">

**Author:** ![improbable22](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/improbable22/32/5464_2.png) [@improbable22](https://discourse.julialang.org/u/improbable22)\
**Post date:** [March 13, 2019, 9:54pm UTC](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700/44 "2019-03-13T21:54:48Z")

</div>

> [@aplavin](#):
>
> Btw, how do you know that one can append `'` to a symbol and still get valid operator name?

It’s [here in the manual](https://docs.julialang.org/en/v1/manual/variables/#Allowed-Variable-Names-1), but NB the addition is `′ == \prime` not `'`.

Being able to write greek letters was (for me) a big enough incentive to ditch anything limited to ASCII. For me at least, Jupyter understands `\alpha + tab` etc (as long as I’m in a code cell). But I agree it’s nice that this isn’t obligatory.

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [March 13, 2019, 9:57pm UTC](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700/45 "2019-03-13T21:57:36Z")

</div>

> [@improbable22](#):
>
> NB the addition is `′ == \prime` not `'`

Oh, really… That’s another reason not to use fancy unicode - confusion 🙂 E.g. I see literally no difference between these symbols in my browser.

> [@improbable22](#):
>
> For me at least, Jupyter understands `\alpha + tab` etc (as long as I’m in a code cell)

Sorry, I wasn’t specific enough. Code cells autocomplete such sequences for me as well, but jupyter text file editor doesn’t.

---

<div class="post-metadata">

**Author:** ![improbable22](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/improbable22/32/5464_2.png) [@improbable22](https://discourse.julialang.org/u/improbable22)\
**Post date:** [March 13, 2019, 10:05pm UTC](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700/46 "2019-03-13T22:05:19Z")

</div>

Yes I have yet to write something with a decorated operator for serious use, partly for confusion reasons. Some other infix operators are clear, like `const \otimes = kron`.

I have never used Jupyter’s text editor. But was very pleased to find recently that my mac can easily map caps lock to the greek keyboard, which mostly removes this need.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [March 13, 2019, 10:27pm UTC](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700/47 "2019-03-13T22:27:12Z")

</div>

We’re getting pretty far afield here, but I absolutely love my [custom defaultkeybindings.dict](http://www.hcs.harvard.edu/~jrus/site/cocoa-text.html) setup for extending emacs-like word navigation with the option key all throughout the OS. And then I also added sequence option-g + alpha to be greek, e.g., option-g + a is α, option-g + b is β, etc. It’s great — and now that I think of it I should similarly extend it for easy super- and sub-scripts.

[https://gist.github.com/mbauman/b54e9ef755caccb9bcfe34b480e627ce](https://gist.github.com/mbauman/b54e9ef755caccb9bcfe34b480e627ce)

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 14, 2019, 7:49am UTC](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700/48 "2019-03-14T07:49:28Z")

</div>

> [@aplavin](#):
>
> wanted to help future new users

If you find something that could be improved on in either the manual in general or specifically the [Differences from other Languages](https://docs.julialang.org/en/v1/manual/noteworthy-differences/) section, making a PR would achieve this.

[Previous page](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700.md?page=2)
