Broadcasting across a nested array

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.

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.

2 Likes

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

1 Like

It’s here in the manual, 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.

2 Likes

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

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

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.

1 Like

We’re getting pretty far afield here, but I absolutely love my custom defaultkeybindings.dict 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

1 Like

If you find something that could be improved on in either the manual in general or specifically the Differences from other Languages section, making a PR would achieve this.

1 Like