Re: How to use `format` to repeat a character

2016-07-11 Thread Bahman Movaqar via Digitalmars-d-learn
On 07/11/2016 03:02 PM, Mike Parker wrote: > You can do it in D with custom format specifiers. See: > > https://wiki.dlang.org/Defining_custom_print_format_specifiers Thanks for the pointer. I'll keep that in mind. -- Bahman

Re: How to use `format` to repeat a character

2016-07-11 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jul 11, 2016 at 02:53:24PM +0430, Bahman Movaqar via Digitalmars-d-learn wrote: > On 07/11/2016 02:44 PM, ketmar wrote: [...] > > the fact that format can insert spaces. it is like: "ok, it can do > > spaces. i bet there should be some way to use any character instead > > of space. after

Re: How to use `format` to repeat a character

2016-07-11 Thread Meta via Digitalmars-d-learn
On Monday, 11 July 2016 at 09:02:12 UTC, Bahman Movaqar wrote: I'm sure I'm missing something very simple but how can I create a string like "" using `format`? I check the docs on `format` and tried many variations including `format("%.*c\n", 4, '-')` but got nowhere. I'd appreciate any

Re: How to use `format` to repeat a character

2016-07-11 Thread Mike Parker via Digitalmars-d-learn
On Monday, 11 July 2016 at 10:23:24 UTC, Bahman Movaqar wrote: On 07/11/2016 02:44 PM, ketmar wrote: On Monday, 11 July 2016 at 09:31:49 UTC, Ali Çehreli wrote: What makes you expect that format should have that feature? :) I somehow recalled I could do that in C and then there was the

Re: How to use `format` to repeat a character

2016-07-11 Thread Bahman Movaqar via Digitalmars-d-learn
On 07/11/2016 02:44 PM, ketmar wrote: > On Monday, 11 July 2016 at 09:31:49 UTC, Ali Çehreli wrote: >> What makes you expect that format should have that feature? :) I somehow recalled I could do that in C and then there was the "minimum field width" in the docs, so I thought it's possible I'm

Re: How to use `format` to repeat a character

2016-07-11 Thread ketmar via Digitalmars-d-learn
On Monday, 11 July 2016 at 09:31:49 UTC, Ali Çehreli wrote: What makes you expect that format should have that feature? :) the fact that format can insert spaces. it is like: "ok, it can do spaces. i bet there should be some way to use any character instead of space. after all, the

Re: How to use `format` to repeat a character

2016-07-11 Thread ag0aep6g via Digitalmars-d-learn
On 07/11/2016 11:31 AM, Ali Çehreli wrote: // Another one that combines multiple range algorithms import std.range : iota; import std.algorithm : map; assert(7.iota.map!(i => i % 2 ? '=' : '-').equal("-=-=-=-")); An alternative without those scary modulo and ternary

Re: How to use `format` to repeat a character

2016-07-11 Thread Ali Çehreli via Digitalmars-d-learn
On 07/11/2016 02:02 AM, Bahman Movaqar wrote: > I'm sure I'm missing something very simple but how can I create a string > like "" using `format`? You can't. > I check the docs on `format` and tried many variations including > `format("%.*c\n", 4, '-')` but got nowhere. What makes you

How to use `format` to repeat a character

2016-07-11 Thread Bahman Movaqar via Digitalmars-d-learn
I'm sure I'm missing something very simple but how can I create a string like "" using `format`? I check the docs on `format` and tried many variations including `format("%.*c\n", 4, '-')` but got nowhere. I'd appreciate any hint/help on this. -- Bahman Movaqar http://BahmanM.com -