Matrix padding

rokke
Sun, 25 Jan 2026 01:54:58 +0000
Internals & Design

ok, I started opening things up to look at doing Pretty-printing small n-d arrays, but I came across a interesting choice which I wanted to make sure wasn’t a deliberate design decision. the left and right padding are completely independent, so arrays of type Any look like they have twice as many cols as they really do:

julia> [1039201 "string"; "tst" 8888; 10 'a'; "row4" 5]
2×2 Matrix{Any}:
 1039201            "string"
        "tst"   8888
      10            'a'
        "row4"     5

. is there any specific reason it shouldn’t be:

julia> [1039201 "string"; "tst" 8888; 10 'a'; "row4" 5]
2×2 Matrix{Any}:
 1039201  "string"
 "tst"        8888
      10  'a'
 "row4"          5

?

edit: ok, guess I figured out why it’s not like above:

julia> ["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 0, 0, 0]
4-element Vector{Any}:
  "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
 0
 0
 0

, but couldn’t it still be something like:

julia> [1039201 "string"; "tst" 8888; 10 'a'; "row4" 5]
2×2 Matrix{Any}:
 1039201  "string"
 "tst"    8888
      10  'a'
 "row4"      5

?

7 posts - 2 participants