On 10/19/22 00:43, Matthew Rushworth via Digitalmars-d-learn wrote:
Thank you, that worked perfectly, not sure exactly what I did wrong, I'm
assuming I forgot to make the parameter a const variable
Object, the root of the class object hierarchy already defines an opEquals [1]
and you need to
On 10/14/22 20:45, mw via Digitalmars-d-learn wrote:
Any suggestions?
There's `dmd -profile=gc` or `dub build --build=profile-gc`.
On 10/14/22 01:43, WhatMeWorry via Digitalmars-d-learn wrote:
Does D provide any guidance as to what is preferred or are they identical for
all intents and purposes?
You won't see a difference for this specific example since the split function
supports character, string and even range
On 10/10/22 08:30, Arun via Digitalmars-d-learn wrote:
Stumbled upon this question on HN
https://news.ycombinator.com/item?id=33142751#33147401
Can I write template A and then apply it to itself to get template B and then
apply that onto template C to get template D.
Does anyone have an
On 10/9/22 03:08, Siarhei Siamashka via Digitalmars-d-learn wrote:
Does the difference really have to be two orders of magnitude for you to
acknowledge that there might be a performance problem in Phobos? [...] Except
that similar one-liners implemented using other programming languages are
On 10/8/22 00:50, Siarhei Siamashka via Digitalmars-d-learn wrote:
On Friday, 7 October 2022 at 12:19:59 UTC, bachmeier wrote:
python -c "print(('a' * 49 + 'b') * 2)" > test.lst
That's generating a file with a single line:
$> wc -l test.lst
1 test.lst
Going with an appropriate 100k mixed
On 10/7/22 01:39, torhu via Digitalmars-d-learn wrote:
regex is about ten times faster then.
Interesting! Using your code, I'm seeing a 1.5x max difference for ldc, nothing
close to 10x. Welp, the woes of superficial benchmarking. :)
On 10/5/22 23:50, torhu via Digitalmars-d-learn wrote:
I did some basic testing, and regex was two orders of magnitude faster. So now
I know, I guess.
And what kind of testing was that? Mind to share? Because I did the following real quick
and wasn't able to measure a "two orders of
On 10/3/22 23:06, Ali Çehreli via Digitalmars-d-learn wrote:
auto rotatedView(R)(R range)
Or even more generic by chaining two slices in case the range permits it:
auto rotatedView(R)(R range, long n = 1)
if (...)
{
if (n == 0) return range;
...
n %= range.length;
On 10/2/22 23:18, mw via Digitalmars-d-learn wrote:
A CSV library should consider all the use cases, and allow users to ignore
certain fields.
Filed issue: https://issues.dlang.org/show_bug.cgi?id=23383
Let's see what others have to say.
On 10/2/22 21:48, mw via Digitalmars-d-learn wrote:
```
text.csvReader!Layout(["b","c","a"]); // Read only these column
```
The intention is very clear: only read the selected columns from the csv, and
for any other fields of class Layout, just ignore (with the default D .init
On 10/2/22 09:24, Fausto via Digitalmars-d-learn wrote:
Thanks a lot. I am to used to C and, more important, I didn't think to look for
also another operator for the power function :)
Oh, and I forgot to mention that this is doing what you probably asked for
originally:
```d
import std;
On 10/2/22 09:24, Fausto via Digitalmars-d-learn wrote:
Thanks a lot. I am to used to C and, more important, I didn't think to look for
also another operator for the power function :)
D does have pow and many other useful math functions [1], it's just not defined
for BitInts. Oh, and
On 10/2/22 00:04, Fausto via Digitalmars-d-learn wrote:
Hello,
I am trying to use pow with an integer argument, but I cannot have a bigint
result, for example, ```pow(10,72)```.
Do I have to write my pow function or is there a native solution?
thanks,
Fausto
In contrast to certain
On 9/28/22 21:36, NonNull via Digitalmars-d-learn wrote:
If I want to read a text file line by line, treating any one of these things as
a newline, there would seem to be no canned way to do that in std.stdio .
1.) What is the best way to achieve this result in D?
If you have structured
On 9/28/22 18:47, torhu via Digitalmars-d-learn wrote:
It works like writefln, so that example would not compile. I forgot to make the
format string explicit, I probably should have done that.
```
private template _messageBox(string title, int style)
{
void _messageBox(T...)(T args)
On 9/28/22 02:04, torhu via Digitalmars-d-learn wrote:
Thank you, works like a charm!
It does? How are you formatting `info("foo", 'a', 42)` inside the template if I
may ask?
On 9/24/22 15:28, Adam D Ruppe via Digitalmars-d-learn wrote:
gdb --args ./your_program
and then it will tell you all the details you want to know about when this
happens.
Thank you for your input, Adam. Real shame that there's no built-in compiler
solution and probably never will be
Recently I refactored some old code of mine, now utilizing classes instead structs, and I got hit
by an uninitialized variable access pattern similar to the simplified example below.
How can we easily spot this? What other switches and safeguards are there?
> dmd -dip1000 -debug -g -w
just
On 9/3/22 23:18, Salih Dincer via Digitalmars-d-learn wrote:
Clean-cut, thank you!
It's very clear to me...
Nothing major, but instead of `uniform!"[]"(DNA.min, DNA.max)`, you can simply
use `uniform!DNA`.
`uniform` considers the whole enum:
On 7/29/22 13:23, pascal111 via Digitalmars-d-learn wrote:
Is there an equivalent in D for C function "strstr" that return the first occurrence of a given
string within another string?
https://en.cppreference.com/w/c/string/byte/strstr
You can use `find` from
On 4/25/22 16:36, cc via Digitalmars-d-learn wrote:
```d
struct Foo {
string s;
this(string s) { this.s = s; }
}
Foo foo = "a";
Foo[] foos = ["a"]; // Error: cannot implicitly convert expression `["a"]` of type `string[]` to
`Foo[]`
Foo[] foos = cast(Foo[]) ["a"]; // Error: e2ir:
On Wednesday, 7 July 2021 at 12:22:11 UTC, BoQsc wrote:
I think nested foreach loops are more readable.
```
import std;
void main()
{
alias alphabet = letters;
char[26] letters = ['a','b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j',
'k', 'l',
On Wednesday, 7 July 2021 at 01:44:20 UTC, Steven Schveighoffer
wrote:
So I have this situation where I need to split a string, then
where the splits are, insert a string to go between the
elements making a new range, all without allocating (hopefully).
Without considering the more general
You can also do:
```d
import std;
void main()
{
// https://dlang.org/phobos/std_ascii.html#.lowercase
"Book.".filter!(c => lowercase.canFind(c))
.each!(c => writeln(c, " found"));
// Output:
// o found
// o found
// k found
}
```
25 matches
Mail list logo