From a6e242cfe17232a6b99de000662438d9cb1aca76 Mon Sep 17 00:00:00 2001 From: Douglas Bates Date: Thu, 31 Oct 2013 11:14:55 -0500 Subject: [PATCH] Print the [] for a vector of length 0 ```jl julia> showcompact(rand(5)) [0.335052,0.678365,0.187975,0.345677,0.981752] julia> showcompact(Float64[]) [] ``` --- base/show.jl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/base/show.jl b/base/show.jl index 68676d4b384ee..a5dfd2cdd62e3 100644 --- a/base/show.jl +++ b/base/show.jl @@ -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) @@ -125,25 +125,25 @@ 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 @@ -151,7 +151,7 @@ function show_delim_array(io::IO, itr, op, delim, cl, delim_one) else newline = true end - end + end end print(io, cl) end