www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Limited printing?

reply "bearophile" <bearophileHUGS lycos.com> writes:
In Mathematica and NumPy (and other systems used with REPL) if 
you print a very large array you receive a shortened output. In 
Mathematica:

http://reference.wolfram.com/mathematica/tutorial/ShortAndShallowOutput.html

Mathematica uses a representation like (but on default it shows 
more items. There is a way to print them all):

Range[100]

{0, 1, 2, <<94>>, 97, 98, 99}


While numpy visualization is a bit simpler:

 from numpy import array
 array([0] * 10)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
 array([0] * 10000)
array([0, 0, 0, ..., 0, 0, 0]) Currently In D this shows all the items: writeln(iota(10_000)); Do you desire some way to have a shortened printing if the generated text is going to be huge? Bye, bearophile
Jan 16 2013
next sibling parent reply "Nicolas Sicard" <dransic gmail.com> writes:
On Wednesday, 16 January 2013 at 11:16:41 UTC, bearophile wrote:
 In Mathematica and NumPy (and other systems used with REPL) if 
 you print a very large array you receive a shortened output. In 
 Mathematica:

 http://reference.wolfram.com/mathematica/tutorial/ShortAndShallowOutput.html

 Mathematica uses a representation like (but on default it shows 
 more items. There is a way to print them all):

 Range[100]

 {0, 1, 2, <<94>>, 97, 98, 99}


 While numpy visualization is a bit simpler:

 from numpy import array
 array([0] * 10)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
 array([0] * 10000)
array([0, 0, 0, ..., 0, 0, 0]) Currently In D this shows all the items: writeln(iota(10_000)); Do you desire some way to have a shortened printing if the generated text is going to be huge? Bye, bearophile
writeln(iota(10_000).take(10)); ?
Jan 16 2013
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Nicolas Sicard:

 writeln(iota(10_000).take(10)); ?
You have missed the point. What if you have a [iota(10_000), iota(10_000)]? Bye, bearophile
Jan 16 2013
parent "Nicolas Sicard" <dransic gmail.com> writes:
On Wednesday, 16 January 2013 at 11:46:10 UTC, bearophile wrote:
 Nicolas Sicard:

 writeln(iota(10_000).take(10)); ?
You have missed the point. What if you have a [iota(10_000), iota(10_000)]?
OK, but is there a simple and general way to tell how to skip elements for ranges other than sorted numeric ones?
Jan 16 2013
prev sibling parent reply "Peter Alexander" <peter.alexander.au gmail.com> writes:
On Wednesday, 16 January 2013 at 11:16:41 UTC, bearophile wrote:
 Do you desire some way to have a shortened printing if the 
 generated text is going to be huge?
I say no. IO isn't always for human consumption (as it usually is in Mathematica). You could very well be printing out as a means of serialisation, and you certainly don't want your data to be trimmed in that case. For a systems programming language, consistency is absolutely critical.
Jan 16 2013
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Peter Alexander:

 I say no. IO isn't always for human consumption (as it usually 
 is in Mathematica). You could very well be printing out as a 
 means of serialisation, and you certainly don't want your data 
 to be trimmed in that case.
Mathematica and NumPy on default shorten the output if it's too much large, and show it all on request. What I forgot to say in my first post is that in D it's probably better to have those conditions swapped, this means printing all on default, and adding a way to produce a shorter output on request. Bye, bearophile
Jan 16 2013
parent "Nicolas Sicard" <dransic gmail.com> writes:
On Wednesday, 16 January 2013 at 14:05:03 UTC, bearophile wrote:
 Mathematica and NumPy on default shorten the output if it's too 
 much large, and show it all on request. What I forgot to say in 
 my first post is that in D it's probably better to have those 
 conditions swapped, this means printing all on default, and 
 adding a way to produce a shorter output on request.
A format specifier like this, then, adding width and/or "precision" to "%(": writefln("%10.3(%s, %)", iota(10_000)); // Prints: "0, 1, 2, ... 7, 8, 9". could be useful.
Jan 16 2013