# Print issue single column array

**URL:** <https://discourse.julialang.org/t/print-issue-single-column-array/85250>\
**Category:** New to Julia\
**Created:** [August 3, 2022, 5:17pm UTC](https://discourse.julialang.org/t/print-issue-single-column-array/85250 "2022-08-03T17:17:26Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbraune](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@mbraune](https://discourse.julialang.org/u/mbraune)\
**Post date:** [August 3, 2022, 5:17pm UTC](https://discourse.julialang.org/t/print-issue-single-column-array/85250/1 "2022-08-03T17:17:27Z")

</div>

printing single column array in version 1.7.3 shows additional empty element:

julia\> A = zeros(Int,3,1)  
3×1 Matrix{Int64}:  
0  
0  
0

julia\> print(A)  
[0; 0; 0;;]  
julia\>

I didn’t see such issue in case of multiple columns,  
and in version 1.6.3 also no such issue, print(A) gives [0; 0; 0] as expected

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [August 3, 2022, 5:25pm UTC](https://discourse.julialang.org/t/print-issue-single-column-array/85250/2 "2022-08-03T17:25:15Z")

</div>

This isn’t an empty element. It’s a change to how higher dimensional arrays are printed. (resulting from new syntax for higher dimensional arrays [Julia 1.7 Highlights](https://julialang.org/blog/2021/11/julia-1.7-highlights/#multidimensional_array_literals))

---

<div class="post-metadata">

**Author:** ![mbraune](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@mbraune](https://discourse.julialang.org/u/mbraune)\
**Post date:** [August 3, 2022, 7:52pm UTC](https://discourse.julialang.org/t/print-issue-single-column-array/85250/3 "2022-08-03T19:52:21Z")

</div>

Thanks a lot for explanation, I understand that 2d 1-column array now can be created using  
A=[1;1;1;;] (same as A=ones(Int,3,1)) .

But still one point:  
if we consider 2d arrays (matrices) only, lets say with 1,2,3,… columns :  
A=zeros(Int,3,1)  
B=zeros(Int,3,2)  
C=zeros(Int,3,3)  
print function will give:  
print(A) [0; 0; 0;;]  
print(B) [0 0; 0 0; 0 0]  
print(C) [0 0 0; 0 0 0; 0 0 0]

this extra ;; for matrix A is not consistent for me,  
and it seems not necessary, since 3 element vector would be printed as [0,0,0] , no mixup with 3x1 matrix, even if written as [0;0;0] .

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [August 4, 2022, 3:53pm UTC](https://discourse.julialang.org/t/print-issue-single-column-array/85250/4 "2022-08-04T15:53:02Z")

</div>

The “problem” here is that we have to find ways to distinguish vectors (one-dimensional thingies) with matrices (two-dimensional thingies) and your `A` is a two-dimensional thingy. Here’s the three variants on Julia REPL

```julia
julia> [0,0,0]
3-element Vector{Int64}:
 0
 0
 0

julia> [0;0;0]
3-element Vector{Int64}:
 0
 0
 0

julia> [0;0;0;;]
3×1 Matrix{Int64}:
 0
 0
 0

```

both `,` and `;` are separators and for single elements you create vectors (see the first two cases) so `;;` indicates the matrix here

---

<div class="post-metadata">

**Author:** ![mbraune](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@mbraune](https://discourse.julialang.org/u/mbraune)\
**Post date:** [August 4, 2022, 8:12pm UTC](https://discourse.julialang.org/t/print-issue-single-column-array/85250/5 "2022-08-04T20:12:23Z")

</div>

Totally agree, for creation of matrices this ;; is big advantage.

My only point is the changed print shape,  
vectors and matrices could easily distinguished by , or ;  
julia\> print([0;0;0])  
[0, 0, 0]  
julia\> print([0,0,0])  
[0, 0, 0]

julia\> print([0;0;0;;])  
[0; 0; 0;;]  
julia\> print([0 0;0 0;0 0])  
[0 0; 0 0; 0 0]

can’t see need or advantage to have this extra ;; in printout of single column case.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 4, 2022, 8:56pm UTC](https://discourse.julialang.org/t/print-issue-single-column-array/85250/6 "2022-08-04T20:56:17Z")

</div>

You need the trailing `;;`, because otherwise you cannot distinguish a length-3 `Vector` from a 3x1 `Matrix`.

> [@mbraune](#):
>
> vectors and matrices could easily distinguished by , or ;

But they’re _not_ distinguished by `,` vs `;`. `[0; 0; 0]` is a length-3 vector, not a matrix. You can convice yourself of this by typing it into the REPL, exactly like @kellertuer showed:

```julia
julia> [0; 0; 0]
3-element Vector{Int64}:
 0
 0
 0

```

Look, it’s a vector, not a matrix! I don’t see how you can argue with that. Printing a matrix like `[0; 0; 0]` would be misleading.

It’s a great advantage if you can take the output of `print(x)`, paste it into the REPL or into a piece of source code, and have it re-create the object `x`.

So this is very much an improvement.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [August 5, 2022, 2:13pm UTC](https://discourse.julialang.org/t/print-issue-single-column-array/85250/7 "2022-08-05T14:13:27Z")

</div>

> [@DNF](#):
>
> Printing a matrix like `[0; 0; 0]` would be misleading.

And perhaps one should recall the role of `;` in Julia as a vertical concatenator:

```julia
julia> [0; [0, 0]]
3-element Vector{Int64}:
 0
 0
 0

```

---

<div class="post-metadata">

**Author:** ![mbraune](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@mbraune](https://discourse.julialang.org/u/mbraune)\
**Post date:** [August 5, 2022, 4:07pm UTC](https://discourse.julialang.org/t/print-issue-single-column-array/85250/8 "2022-08-05T16:07:02Z")

</div>

I dont understand why this is necessary:  
`julia> [0,0,0] == [0;0;0] true`  
is there deeper reason, why `;` does not create matrix ?

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 5, 2022, 4:34pm UTC](https://discourse.julialang.org/t/print-issue-single-column-array/85250/9 "2022-08-05T16:34:54Z")

</div>

`[;]` denotes vertical concatenation. Two vectors `u` and `v` can be concatenated into a larger vector `[u; v]`. If you concatenate matrices, they turn into a larger matrix. The logical extension of this is that doing the same with scalars creates a vector.

---

<div class="post-metadata">

**Author:** ![mbraune](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@mbraune](https://discourse.julialang.org/u/mbraune)\
**Post date:** [August 7, 2022, 7:14pm UTC](https://discourse.julialang.org/t/print-issue-single-column-array/85250/10 "2022-08-07T19:14:57Z")

</div>

Thanks to all for explaining, I begin to understand the problem, more beginner questions will not contribute here.  
Conclusion for me is

```julia
julia> print(zeros(Int,3,1))
[0; 0; 0;;]

julia> print(zeros(Int,3,2))
[0 0; 0 0; 0 0]

```

is just minor cosmetic issue. Discussion regarding role of `;` as vertical concatenator goes far beyond scope of this thread.
