You have to implement printing somehow (unfortunately, I don’t think Base.showarray is modular enough to do what you want, but maybe someone will provide a solution using it). This is another way:
function show_vector_sans_type(io, v::AbstractVector)
print(io, "[")
for (i, elt) in enumerate(v)
i > 1 && print(io, ", ")
print(io, elt)
end
print(io, "]")
end
show_vector_sans_type(v::AbstractVector) =
show_vector_sans_type(IOContext(STDOUT; :compact => true), v)
show_vector_sans_type(x)
@Tamas_Papp that is basically the type of function I am using in my Dendriform.jl package to print arrays.
I think if you have a specific need for printing things in a package, it makes sense to just define your own.
Another complaint I had previously is the spaces that have been inserted into the syntax, as I explained here:
My solution was to modify the Base.show_delim_array function to get rid of the spaces. (not showarray)
Just a minor change in case someone else also want this pretty print on @Tamas_Papp solution.
This handles vectors in vectors, maybe it is useful for someone else too.
unction show_vector_sans_type(io, v::AbstractVector)
print(io, "[")
for (i, elt) in enumerate(v)
i > 1 && print(io, ", ")
if elt isa AbstractVector
show_vector_sans_type(io, elt)
else
print(io, elt)
end
end
print(io, "]")
end
show_vector_sans_type(v::AbstractVector) = show_vector_sans_type(stdout, v)