mars-d- learn wrote:
> > ```D
> > import std.datetime : Clock, format;
> > import std.stdio : writeln;
> >
> > void main()
> > {
> > auto currentTime = Clock.currTime;
> >
> > auto formattedTime = currentTime.format(&quo
> import std.datetime : Clock, format;
> > > import std.stdio : writeln;
> > >
> > > void main()
> > > {
> > > auto currentTime = Clock.currTime;
> > >
> > > auto formattedTime = currentTime.format("%Y-%m-%d %H:%M:%
t;> ```D
> >> import std.datetime : Clock, format;
> >> import std.stdio : writeln;
> >>
> >> void main()
> >> {
> >>
> >> auto currentTime = Clock.currTime;
> >>
> >> auto format
On Thursday, 18 January 2024 at 23:26:42 UTC, zoujiaqing wrote:
```D
import std.datetime : Clock, format;
import std.stdio : writeln;
void main()
{
auto currentTime = Clock.currTime;
auto formattedTime = currentTime.format("%Y-%m-%d
%H:%M:%S");
writeln("
On Thursday, 18 January 2024 at 23:43:13 UTC, Jonathan M Davis
wrote:
On Thursday, January 18, 2024 4:26:42 PM MST zoujiaqing via
Digitalmars-d- learn wrote:
```D
import std.datetime : Clock, format;
import std.stdio : writeln;
void main()
{
auto currentTime = Clock.currTime;
auto
On Thursday, January 18, 2024 4:26:42 PM MST zoujiaqing via Digitalmars-d-
learn wrote:
> ```D
> import std.datetime : Clock, format;
> import std.stdio : writeln;
>
> void main()
> {
> auto currentTime = Clock.currTime;
>
> auto formattedTime = currentTim
```D
import std.datetime : Clock, format;
import std.stdio : writeln;
void main()
{
auto currentTime = Clock.currTime;
auto formattedTime = currentTime.format("%Y-%m-%d %H:%M:%S");
writeln("Formatted Time: ", formattedTime);
}
```
in that case it's more like a format %s,
that takes another path.
Only a small thing, but is it intended that:
```
void main() {
// static assert (false, "Static Assert triggered");
assert(false, "Assert triggered");
}
```
produces
```
core.exception.AssertError@staticassertex01.d(4): Assert triggered
```
but removing the // produces
```
staticassertex01.d(
d help -
maybe my editor already has syntax highlighting for it.
I think it's a bespoke format with no official name. The closest
thing to a spec is this page:
https://dlang.org/articles/code_coverage.html
or was the .lst extension chosen arbitrarily?
my text editor [notepad++] thinks it's COBOL for some reason but
that's obviously not correct, so i'm wondering if it has an
official spec or anything. knowing the name of it would help -
maybe my editor already has syntax highlighting for it.
On Sunday, 23 January 2022 at 22:08:28 UTC, Ali Çehreli wrote:
You use an asterisk and provide the width as an argument. This
one uses the length of the name of the program:
import std;
void main(string[] args)
{
int val = 999000;
writefln("[%*s]", args.front.length, val); // [ 999000]
On 1/23/22 13:59, forkit wrote:
I would like to calculate the width of the format specifier dynamically,
at runtime.
You use an asterisk and provide the width as an argument. This one uses
the length of the name of the program:
import std;
void main(string[] args)
{
int val = 999000
I would like to calculate the width of the format specifier
dynamically, at runtime.
e.g int WIDTH = something.length;
then my format specifier would be: %WIDTHs instead of %9s
// ---
module test;
import std;
void main()
{
int val = 999000;
writefln("[%9s]", val); // [ 999000]
}
// ---
On Saturday, 20 November 2021 at 01:01:05 UTC, rikki cattermole
wrote:
Don't use ~> for branches.
...
Thank you very much. I edited the dub.json, and that fixed the
problem(anyways, there is no longer a "testing" branch, so that
would have also been an issue.)
Don't use ~> for branches.
alpha@DESKTOP-RB97SA4 /tmp/dutils
$ dub build
Invalid SemVer format: stable.0.0
alpha@DESKTOP-RB97SA4 /tmp/dutils
$ nano dub.json
alpha@DESKTOP-RB97SA4 /tmp/dutils
$ dub build
Performing "debug" build using
C:\Tools\D\dmd_2.097.2\windows\bin\
On Friday, 12 November 2021 at 21:22:32 UTC, Ruby The Roobster
wrote:
On Thursday, 11 November 2021 at 01:57:10 UTC, rikki cattermole
wrote:
On 11/11/2021 2:13 PM, Ruby The Roobster wrote:
Branch ~master: Invalid SemVer format: testing.0.0
Branch ~testing: Invalid SemVer format: testing.0.0
On Thursday, 11 November 2021 at 01:57:10 UTC, rikki cattermole
wrote:
On 11/11/2021 2:13 PM, Ruby The Roobster wrote:
Branch ~master: Invalid SemVer format: testing.0.0
Branch ~testing: Invalid SemVer format: testing.0.0
Version 0.1.2: Invalid SemVer format: testing.0.0
testing is a branch
On 11/11/2021 2:13 PM, Ruby The Roobster wrote:
Branch ~master: Invalid SemVer format: testing.0.0
Branch ~testing: Invalid SemVer format: testing.0.0
Version 0.1.2: Invalid SemVer format: testing.0.0
testing is a branch.
You are using ~>testing for it.
To use a branch in the SEMVER
# Dub says that there is an invalid semVer format, but I don't
see how.
[Relevant Package:](https://code.dlang.org/packages/dutils)
Recently, I added a new tag: v0.1.2 to the github repo, as well
as v0.1.2-rc.1(this was later removed.) Now whenever updating the
package, dub gives me
On 8/9/21 10:03 PM, nov wrote:
> i dreamed that programming will be less-error with compile checking
format.
I still think so because many errors that can be caught at compile time
are moved to run time in non-statically-typed languages.
> but reality disappoint :(
> message
On Tuesday, 10 August 2021 at 05:03:12 UTC, nov wrote:
every time i try to use templates, i have problems :(
That is why C++ introduced concepts. Wonder when D will be
getting them :(
esult often contains
something like "init" or "cast(int*)mytype"
i dreamed that programming will be less-error with compile
checking format.
but reality disappoint :(
message for every error in compile-checked format occupy whole
screen :(
every time i try to use templates, i have problems :(
On 8/9/21 3:46 PM, Adam D Ruppe wrote:
> The compile time checker [...] implementation is really really
> slow and pretty bloated in codegen too.
>
> My personal policy is to never use it.
My personal policy is to kindly ask you to fix it! :p
Ali
On Monday, 9 August 2021 at 22:30:43 UTC, Ali Çehreli wrote:
I don't know the reason but I suspect a bug in the compile-time
checker that involves .init values for arguments.
The compile time checker is pretty bad tbh, it just tries to ctfe
execute the given string and sees if it throws. That'
On 8/9/21 3:01 PM, Patrick Schluter wrote:
> On Monday, 9 August 2021 at 19:38:28 UTC, novice2 wrote:
>> format!"fmt"() and writef!"fmt"() templates
>> with compile-time checked format string
>> not accept %X for pointers,
>>
>> but format()
On Monday, 9 August 2021 at 22:01:18 UTC, Patrick Schluter wrote:
On Monday, 9 August 2021 at 19:38:28 UTC, novice2 wrote:
format!"fmt"() and writef!"fmt"() templates
with compile-time checked format string
not accept %X for pointers,
but format() and writef() accept it
On Monday, 9 August 2021 at 19:38:28 UTC, novice2 wrote:
format!"fmt"() and writef!"fmt"() templates
with compile-time checked format string
not accept %X for pointers,
but format() and writef() accept it
https://run.dlang.io/is/aQ05Ux
```
void main() {
import std.stdi
format!"fmt"() and writef!"fmt"() templates
with compile-time checked format string
not accept %X for pointers,
but format() and writef() accept it
https://run.dlang.io/is/aQ05Ux
```
void main() {
import std.stdio: writefln;
int x;
writefln("%X", &
On Saturday, 22 May 2021 at 03:14:35 UTC, cc wrote:
Oops, disregard this. I had an error in my imports.😓
It does in fact work in @safe.
I should add as an aside then that there is an issue of errors
from the body of a toString template not being displayed, and
instead the template being sile
On Saturday, 22 May 2021 at 03:07:10 UTC, cc wrote:
Ahh, in that case it would appear formattedWrite isn't @safe at
all. Looks like you have to stick with put()?
```d
@safe void toString(W)(ref W writer) if (isOutputRange!(W,
char)) {
//writer.formattedWrite!("FOO:%s", x); // fails
On Friday, 21 May 2021 at 16:53:48 UTC, drug wrote:
21.05.2021 18:28, cc пишет:
On Friday, 21 May 2021 at 14:19:03 UTC, newbie wrote:
Thank you, and formatValue?
formattedWrite should handle this.
```d
@safe struct Foo {
int x = 3;
void toString(W)(ref W writer) if (isOutputRange!(
On Friday, 21 May 2021 at 14:19:03 UTC, newbie wrote:
Thank you, and formatValue?
formattedWrite should handle this.
```d
@safe struct Foo {
int x = 3;
void toString(W)(ref W writer) if (isOutputRange!(W, char)) {
writer.formattedWrite("Foo(%s)", x);
}
}
On Friday, 21 May 2021 at 13:59:13 UTC, drug wrote:
21.05.2021 16:45, newbie пишет:
I am following
https://wiki.dlang.org/Defining_custom_print_format_specifiers, why sink and formatValue are not @safe? What are the best practice for toString in safe code? Thank you
sink is obsolete now, use W
21.05.2021 16:45, newbie пишет:
I am following
https://wiki.dlang.org/Defining_custom_print_format_specifiers, why sink
and formatValue are not @safe? What are the best practice for toString
in safe code? Thank you
sink is obsolete now, use W(riter)
```D
import std.range : isOutputRange;
vo
I am following
https://wiki.dlang.org/Defining_custom_print_format_specifiers,
why sink and formatValue are not @safe? What are the best
practice for toString in safe code? Thank you
On Saturday, 24 April 2021 at 04:09:15 UTC, Mike Parker wrote:
On Saturday, 24 April 2021 at 03:40:20 UTC, Jack wrote:
Can I rely on this format from fullyQualifiedName? for
example, let's say I do:
```d
enum s = fullyQualifiedName!f.split;
```
where f is a function member of a class.
On Saturday, 24 April 2021 at 03:40:20 UTC, Jack wrote:
Can I rely on this format from fullyQualifiedName? for example,
let's say I do:
```d
enum s = fullyQualifiedName!f.split;
```
where f is a function member of a class. Can I realy that s[0]
is the module name, s[1] is the class nam
Can I rely on this format from fullyQualifiedName? for example,
let's say I do:
```d
enum s = fullyQualifiedName!f.split;
```
where f is a function member of a class. Can I realy that s[0] is
the module name, s[1] is the class name and s[2] the functio
name? is this standard or ca
On Wednesday, 7 April 2021 at 17:31:09 UTC, Paul Backus wrote:
On Wednesday, 7 April 2021 at 17:04:56 UTC, novice2 wrote:
On Wednesday, 7 April 2021 at 13:43:18 UTC, Paul Backus wrote:
So, you should change your code to
writefln("%-(%s, %)", s);
sorry i dont read docs so carefully
thanks
On Wednesday, 7 April 2021 at 17:31:09 UTC, Paul Backus wrote:
It's not your fault--this is a pretty obscure feature, and it's
not documented very well. Even after you've found the correct
page in the documentation (the page for `formattedWrite` [1]),
you have to scroll down past multiple examp
On 4/7/21 10:04 AM, novice2 wrote:
On Wednesday, 7 April 2021 at 13:43:18 UTC, Paul Backus wrote:
So, you should change your code to
writefln("%-(%s, %)", s);
sorry i dont read docs so carefully
thanks
For the sake of completeness, I mention this feature in a couple of
other places:
On Wednesday, 7 April 2021 at 17:04:56 UTC, novice2 wrote:
On Wednesday, 7 April 2021 at 13:43:18 UTC, Paul Backus wrote:
So, you should change your code to
writefln("%-(%s, %)", s);
sorry i dont read docs so carefully
thanks
It's not your fault--this is a pretty obscure feature, and it
On Wednesday, 7 April 2021 at 13:43:18 UTC, Paul Backus wrote:
So, you should change your code to
writefln("%-(%s, %)", s);
sorry i dont read docs so carefully
thanks
format specifier, strings and characters are
escaped automatically. To avoid this behavior, add '-' flag to
"%(".
So, you should change your code to
writefln("%-(%s, %)", s);
https://run.dlang.io/is/p4NVp8
```d
void main()
{
import std.stdio: writefln;
string[] s = ["a", "b", "c"];
writefln("%(%s, %)", s);
}
```
output
```d
"a", "b", "c"
```
expected
```d
a, b, c
```
there is extra quotes, wich not present in firmat specifier.
is this bug, or i should chan
On 3/14/21 9:36 PM, sharkloc wrote:
I want to read the content(file.gz) line by line,the following code is
not friendly to large files of hundreds of Gb, and the memory overhead
is also very large.
import std.stdio;
import std.process;
import std.string;
void main(string[] args){
strin
On Monday, 15 March 2021 at 01:36:08 UTC, sharkloc wrote:
I want to read the content(file.gz) line by line,the following
code is not friendly to large files of hundreds of Gb, and the
memory overhead is also very large.
You can use the internal zlib instead of a shell. This example is
using s
I want to read the content(file.gz) line by line,the following
code is not friendly to large files of hundreds of Gb, and the
memory overhead is also very large.
import std.stdio;
import std.process;
import std.string;
void main(string[] args){
string fileName = args[1];
stri
On Sunday, 15 November 2020 at 03:14:07 UTC, Marcone wrote:
I want to convert seconds to hour, minut and second.
Do you want to convert a *duration* into hours/minutes/seconds,
or format a UNIX *timestamp* to hours/minutes/seconds? These are
conceptually two different things
On Sunday, 15 November 2020 at 03:15:29 UTC, Anonymouse wrote:
On Sunday, 15 November 2020 at 03:08:48 UTC, Marcone wrote:
On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote:
On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote:
auto mytime = Clock.currTime().toUnixTime()
wri
On Sunday, 15 November 2020 at 03:15:29 UTC, Anonymouse wrote:
On Sunday, 15 November 2020 at 03:08:48 UTC, Marcone wrote:
On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote:
On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote:
auto mytime = Clock.currTime().toUnixTime()
wri
On Sunday, 15 November 2020 at 03:08:48 UTC, Marcone wrote:
On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote:
On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote:
auto mytime = Clock.currTime().toUnixTime()
writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some
like
On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote:
On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote:
auto mytime = Clock.currTime().toUnixTime()
writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some
like this in D?
auto mytime = Clock.currTime;
writefln("%02dh:%
On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote:
On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote:
auto mytime = Clock.currTime().toUnixTime()
writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some
like this in D?
auto mytime = Clock.currTime;
writefln("%02dh:%
On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote:
auto mytime = Clock.currTime().toUnixTime()
writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some
like this in D?
auto mytime = Clock.currTime;
writefln("%02dh:%02dm:%02ds", mytime.hour, mytime.minute,
mytime.second);
auto
auto mytime = Clock.currTime().toUnixTime()
writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some
like this in D?
re ( needed in the
> > > format string?
> >
> > The %( ... %) stuff is expanded and repeated for each element inside
> > the given array.
>
> Thanks, it seems there are some pretty powerful formatting options:
>
> https://dlang.org/phobos/std_format.html
Indeed.
%
On Monday, 12 October 2020 at 00:59:33 UTC, Adam D. Ruppe wrote:
On Monday, 12 October 2020 at 00:46:37 UTC, Imperatorn wrote:
To people trying to learn, why is that % before ( needed in
the format string?
The %( ... %) stuff is expanded and repeated for each element
inside the given array
On 10/11/20 5:44 PM, Max Haughton wrote:
> Possibly worth showing off (especially given that some people at first
> don't even know the templated format string exists)
This feature is already among my slides for an upcoming conference. ;)
Ali
On Monday, 12 October 2020 at 00:46:37 UTC, Imperatorn wrote:
To people trying to learn, why is that % before ( needed in the
format string?
The %( ... %) stuff is expanded and repeated for each element
inside the given array.
On Sunday, 11 October 2020 at 23:57:31 UTC, Ali Çehreli wrote:
I find D's %( and %) range format specifiers very useful:
import std.stdio;
import std.range;
void main() {
5.iota.writefln!"%(%s, %)"; // Prints 0, 1, 2, 3, 4
}
Are there similar features in other languages?
On Sunday, 11 October 2020 at 23:57:31 UTC, Ali Çehreli wrote:
I find D's %( and %) range format specifiers very useful:
import std.stdio;
import std.range;
void main() {
5.iota.writefln!"%(%s, %)"; // Prints 0, 1, 2, 3, 4
}
Are there similar features in other languages?
I find D's %( and %) range format specifiers very useful:
import std.stdio;
import std.range;
void main() {
5.iota.writefln!"%(%s, %)"; // Prints 0, 1, 2, 3, 4
}
Are there similar features in other languages?
Thank you,
Ali
On Tuesday, 6 October 2020 at 16:46:28 UTC, Severin Teona wrote:
Also, when I try to link the druntime with the application I
want to write on the microcontroller, there are some link
errors due to the file format.
This happens when you link manually, not through LDC. When
running LDC with
tion I had was to use Link Time
Optimization (LTO) to reduce the size.
The problem now is the fact that when I compile the druntime
with -flto=full or -flto=thin (as arguments for LDC2), the
resulted object files (and also a big part of the runtime as it
is a static library) have a different f
ize.
The problem now is the fact that when I compile the druntime with
-flto=full or -flto=thin (as arguments for LDC2), the resulted
object files (and also a big part of the runtime as it is a
static library) have a different file format - LLVM IR bitcode -
than I need, which is ELF 32-bit.
On Sunday, 27 September 2020 at 21:41:25 UTC, Adam D. Ruppe wrote:
On Sunday, 27 September 2020 at 21:38:43 UTC, ddcovery wrote:
i.e. checking this Regex expression
`^[a-zA-Z_]*[a-zA-Z0-9_]*[a-zA-Z][a-zA-Z0-9_]*$`
Is there any way to check a regular expression at compile time?
Not really an
On Sunday, 27 September 2020 at 21:38:43 UTC, ddcovery wrote:
i.e. checking this Regex expression
`^[a-zA-Z_]*[a-zA-Z0-9_]*[a-zA-Z][a-zA-Z0-9_]*$`
Is there any way to check a regular expression at compile time?
Not really and I'd actually suggest not trying because even if it
did work, it'd
I have a "variation" of "unaryFun" that I name "unaryProp" that,
basically, doesn't require to specify "a." at the beginning of
the expression.
template unaryProp(alias propName)
{
static assert(is(typeof(propName) : string), "Sorry, propName
must be an string");
auto unaryProp(ElementTy
ore I need to accurately store the file
modification SysTime in binary format, so that I can later
load this SysTime from the snapshot file to compare it with
the current file modification SysTime.
Having unfortunately not understood how to do this from the
SysTime documentation, in despair,
On 7/21/20 7:44 AM, Ecstatic Coder wrote:
On Tuesday, 21 July 2020 at 11:01:20 UTC, drug wrote:
On 7/20/20 10:04 PM, Ecstatic Coder wrote:
I'm currently implementing a small open source backup tool (dub), and
therefore I need to accurately store the file modification SysTime in
binary f
On 7/21/20 2:44 PM, Ecstatic Coder wrote:
Ah thanks for telling me :)
The loaded byte array in the union type was indeed the same as the saved
one, so I immediately thought it was crashing because of some hidden
pointer for timezone or something which was then pointing to garbage at
reloadin
On Tuesday, 21 July 2020 at 11:01:20 UTC, drug wrote:
On 7/20/20 10:04 PM, Ecstatic Coder wrote:
I'm currently implementing a small open source backup tool
(dub), and therefore I need to accurately store the file
modification SysTime in binary format, so that I can later
load this Sy
On 7/20/20 10:04 PM, Ecstatic Coder wrote:
I'm currently implementing a small open source backup tool (dub), and
therefore I need to accurately store the file modification SysTime in
binary format, so that I can later load this SysTime from the snapshot
file to compare it with the current
As my question obviously didn't interest any expert, I took
advantage of my lunch break to do some more research ;)
Maybe I'm wrong, but to my knowledge, there is no function to get
the number of hectonanoseconds since January 1, 1970.
Fortunately I can get the number of seconds since the sam
I'm currently implementing a small open source backup tool (dub),
and therefore I need to accurately store the file modification
SysTime in binary format, so that I can later load this SysTime
from the snapshot file to compare it with the current file
modification SysTime.
H
On Wednesday, 17 June 2020 at 12:39:11 UTC, FeepingCreature wrote:
On Wednesday, 17 June 2020 at 12:30:24 UTC, Quantium wrote:
Hi all! I have a programm in D (The simplest OS), which should
be compiled into .bin or .iso format to be possible to run it
on VirtualBox. How can I compile it to
On Wednesday, 17 June 2020 at 12:30:24 UTC, Quantium wrote:
Hi all! I have a programm in D (The simplest OS), which should
be compiled into .bin or .iso format to be possible to run it
on VirtualBox. How can I compile it to .bin / .iso format and
which compiler should I use?
Try this page
Hi all! I have a programm in D (The simplest OS), which should be
compiled into .bin or .iso format to be possible to run it on
VirtualBox. How can I compile it to .bin / .iso format and which
compiler should I use?
nswer.
for simple hex/binary/etc printing use
import std.conv;
pragma(msg, i.to!string(16));
where you can replace 16 with your target base.
You can also use format as in the previous reply if you want
more formatting control
That's great. Thanks for the fast reply. To both of you :)
.conv;
pragma(msg, i.to!string(16));
where you can replace 16 with your target base.
You can also use format as in the previous reply if you want more
formatting control
On Thursday, 14 May 2020 at 09:49:15 UTC, wjoe wrote:
Is there an easy way to print an int in hexadecimal, octal or
binary representation ?
The documentation on pragma(msg, ...) and a quick web search
didn't provide an answer.
import std.string;
pragma(msg, format("%x",
Is there an easy way to print an int in hexadecimal, octal or
binary representation ?
The documentation on pragma(msg, ...) and a quick web search
didn't provide an answer.
On 31/01/2020 09:45, bauss wrote:
> On Friday, 31 January 2020 at 07:20:17 UTC, cc wrote:
>> char[4096] buf;
>> writeln(GC.stats.usedSize);
>> foreach (i; 0 .. 10) {
>> sformat(buf, "%f", 1.234f);
>> writeln(GC.stats.usedSize);
>> }
>>
>> Output with DMD32 D Compi
On Friday, 31 January 2020 at 08:45:55 UTC, bauss wrote:
On Friday, 31 January 2020 at 07:20:17 UTC, cc wrote:
char[4096] buf;
writeln(GC.stats.usedSize);
foreach (i; 0 .. 10) {
sformat(buf, "%f", 1.234f);
writeln(GC.stats.usedSize);
On Friday, 31 January 2020 at 07:20:17 UTC, cc wrote:
char[4096] buf;
writeln(GC.stats.usedSize);
foreach (i; 0 .. 10) {
sformat(buf, "%f", 1.234f);
writeln(GC.stats.usedSize);
}
Output with DMD32 D Compiler v2.089.1-dirty (Win10 x6
char[4096] buf;
writeln(GC.stats.usedSize);
foreach (i; 0 .. 10) {
sformat(buf, "%f", 1.234f);
writeln(GC.stats.usedSize);
}
Output with DMD32 D Compiler v2.089.1-dirty (Win10 x64):
16
16
16
...
Output with DMD32 D Compiler v2.090.0
On Tuesday, 28 January 2020 at 08:54:16 UTC, Simen Kjærås wrote:
import std.stdio : writefln;
import std.format : format;
import std.algorithm : map;
auto vec = [1000, 2000, 3000];
writefln("%-(%s\t%)", vec.map!(e => format!"%,2?d"('_',
e))
On Tuesday, 28 January 2020 at 07:36:25 UTC, Malte wrote:
I want to format an array using the %(...%) syntax. How can I
change the separator? I tried to use ? and add it as additional
parameter, but that doesn't seem to work on arrays:
import std;
void main()
{
writeln("
I want to format an array using the %(...%) syntax. How can I
change the separator? I tried to use ? and add it as additional
parameter, but that doesn't seem to work on arrays:
import std;
void main()
{
writeln("This works:");
writefln("%,2?d", '_
On Saturday, 18 January 2020 at 09:33:34 UTC, mark wrote:
Is there a tool that will sort imports (e.g., as per the style
guide), and that will also add the specific names used?
D-Scanner[1] will warn you about non sorted imports
You need to set imports_sortedness="enabled" on your dscanner.ini
Is there a tool that will sort imports (e.g., as per the style
guide), and that will also add the specific names used?
Also, is there a D source formatting tool (ideally with options
to set a max line length and choice of braces style)?
Is there any runtime (or compiletime) cost to just listi
On 11/19/19 7:28 PM, Petar Kirov [ZombineDev] wrote:
In cases where I have some aggregate data, but I don't feel like writing
a custom toString method, I often wrap the data in a Tuple and use its
[1] %(inner%) or %(inner%|sep%) format specifiers. Here's an example:
import std;
On Tuesday, 19 November 2019 at 21:50:08 UTC, Steven
Schveighoffer wrote:
I know I can format a range with a format string that contains
%(%s, %). And this results in a nice comma separated list for
each item.
But what about an item that has a not-so-cookie-cutter format?
Like for instance a
I know I can format a range with a format string that contains %(%s, %).
And this results in a nice comma separated list for each item.
But what about an item that has a not-so-cookie-cutter format? Like for
instance a name/value field:
struct NV
{
string name;
int value;
}
If I want to
On Sunday, 14 July 2019 at 13:45:38 UTC, Ron Tarrant wrote:
'Morning, all.
If these lines:
string currency = format("$%,.02f", 11_234_456.99);
writeln(currency);
Will result in:
$11,234,456.99
Why don't these lines:
string notCurrency = format("%,&
'Morning, all.
If these lines:
string currency = format("$%,.02f", 11_234_456.99);
writeln(currency);
Will result in:
$11,234,456.99
Why don't these lines:
string notCurrency = format("%,", 11_234_456);
writeln(notCurrency);
result in:
11,23
On 12/16/2018 12:00 PM, Steven Schveighoffer wrote:
>> Now there is a compilation error:
>>
>>Orphan format arguments: args[0..1]
>
> Hm... maybe a runtime error? I didn't think the compiler knows to
> complain about this.
Sorry, it was a runtime error. (I wa
On 12/15/18 7:34 PM, Ali Çehreli wrote:
This one confused me until I decided to talk to a rubber ducky:
import std.string;
void main() {
auto s = "%s is a good number".format(42);
}
Fine; it works... Then the string becomes too long and I split it:
auto s = "%s is a
1 - 100 of 372 matches
Mail list logo