3 ms·
> Okay, but '[[1,2,3] [4,5,6]] .+ 4` does work! Looks like Julia distinguishes between a two-dimensional array and an array of arrays Ah, yes, Julia distinguis
by eigenspace 2y ago
> Okay, but '[[1,2,3] [4,5,6]] .+ 4` does work! Looks like Julia distinguishes between a two-dimensional array and an array of arrays
Ah, yes, Julia distinguishes between multidimensional arrays, and arrays of arrays.
The thing you wrote is actually syntax sugar for “horizontal concatenation” (hcat), I.e. when one writes `[A B]` that makes a flat matrix. So what you wrote is actually just (mildly confusing) syntax sugar for the matrix
[1 4
2 5
3 6]
which is an array of scalars in julia, not an array of arrays. If you had written `[[1,2,3], [4,5,6]] .+ 4` you’d have an array of arrays, and hence an error.
Given that Furthark chose to have multidimensional arrays being semantically arrays-of-arrays, I see why it’s important for you to automatically descend recursively through multiple levels.
I still think it’s maybe a bit of a footgun that users cant choose at the call-site if their function is broadcasted or not though (that’s the really nice thing about julia’s dot-broadcasting for me anyways).