From feb676a07be2ae5cf8c1c9bf8668995409eb3d43 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Mon, 6 Jan 2020 12:25:18 +0100 Subject: [PATCH 1/2] `show` only first 10 elements --- src/Lazy.jl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Lazy.jl b/src/Lazy.jl index 74976b8..775985f 100644 --- a/src/Lazy.jl +++ b/src/Lazy.jl @@ -144,18 +144,18 @@ end ########### # Printing ########### - -Base.show(io::IO, xs::List) = - foreach(x->print(io,x), ["("] * interpose(xs, " ") * [")"]) - -function show(io::IO, ::MIME"text/plain", xs::List) - isempty(xs) && return println(io, "List()") - - print(io, "List:") - for x in xs - print(io, "\n ") - show(io, x) +maxlen(xs::List) = min(length(xs), 10) + +function Base.show(io::IO, xs::List) + print(io, "List: (") + for (i, x) in enumerate(interpose(xs, " ")) + print(io, x) + if i > 21 + print(io, "…") + break + end end + print(io, ")") end # Some example lists From c1ac55859d7f637579e28296300f896bdf316cb8 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Mon, 6 Jan 2020 12:26:19 +0100 Subject: [PATCH 2/2] remove unnecessary method --- src/Lazy.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Lazy.jl b/src/Lazy.jl index 775985f..c14fc41 100644 --- a/src/Lazy.jl +++ b/src/Lazy.jl @@ -144,8 +144,6 @@ end ########### # Printing ########### -maxlen(xs::List) = min(length(xs), 10) - function Base.show(io::IO, xs::List) print(io, "List: (") for (i, x) in enumerate(interpose(xs, " "))