Skip to content

Commit

Permalink
Print the [] for a vector of length 0
Browse files Browse the repository at this point in the history
```jl
julia> showcompact(rand(5))
[0.335052,0.678365,0.187975,0.345677,0.981752]
julia> showcompact(Float64[])
[]
```
  • Loading branch information
dmbates committed Oct 31, 2013
1 parent 8cc8880 commit a6e242c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ function show(io::IO, x::DataType)
end

function showcompact{T<:Number}(io::IO, x::Vector{T})
print(io, "[")
if length(x) > 0
print(io, "[")
showcompact(io, x[1])
for j in 2:length(x)
print(io, ",")
showcompact(io, x[j])
end
print(io, "]")
end
print(io, "]")
end
showcompact(io::IO, x) = show(io, x)
showcompact(x) = showcompact(STDOUT::IO, x)
Expand Down Expand Up @@ -125,33 +125,33 @@ function show_delim_array(io::IO, itr, op, delim, cl, delim_one)
newline = true
first = true
if !done(itr,state)
while true
while true
if isa(itr,Array) && !isdefined(itr,state)
print(io, undef_ref_str)
state += 1
multiline = false
else
x, state = next(itr,state)
x, state = next(itr,state)
multiline = isa(x,AbstractArray) && ndims(x)>1 && length(x)>0
if newline
if multiline; println(io); end
end
show(io, x)
show(io, x)
end
if done(itr,state)
if done(itr,state)
if delim_one && first
print(io, delim)
end
break
end
break
end
first = false
print(io, delim)
if multiline
println(io); println(io); newline=false
else
newline = true
end
end
end
end
print(io, cl)
end
Expand Down

0 comments on commit a6e242c

Please sign in to comment.