Formatted output ranges

Ivan Kazmenko via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 17 02:25:40 PDT 2015


On Saturday, 11 April 2015 at 22:45:39 UTC, Dennis Ritchie wrote:
> I also want to know whether it is possible to D somehow set the 
> maximum width of the print string in characters?
>
> -----
> void main() {
> 	import std.stdio, std.range;
> 	writefln(";; %(%s, %)).", iota(10, 1101));
> }
> -----
>
> For example, here's the code to Common Lisp which is given by 
> the width of the line is 30 characters:
> -----
> (let ((a (loop :for i :from 10 :to 1100 :collect i)))
> 	(format t "~%;;~{ ~<~%;; ~1,30:;~S~>~^,~}.~%" a))
> -----
> http://ideone.com/hGguge

Looks like there's std.string.wrap to do that:
http://forum.dlang.org/thread/mgqiji$727$1@digitalmars.com


More information about the Digitalmars-d-learn mailing list