On Sunday, 27 December 2020 at 18:25:10 UTC, sighoya wrote:
This should work:
```
static assert(is(int == AliasSeq!int));
Drepl: static assert: `is(int == (int))` is false
```
That will only work for type tuples. We need a general solution
that would work for any alias tuple.
The most ap
On Monday, 28 December 2020 at 07:00:59 UTC, Ali Çehreli wrote:
On 12/27/20 10:24 PM, Kirill wrote:
Hello, is there a tool to measure the execution time of a
function in D? Can the GC do it?
StopWatch and benchmark():
https://dlang.org/phobos/std_datetime.html
Ali
Thanks Ali! That's exac
On 12/27/20 10:24 PM, Kirill wrote:
Hello, is there a tool to measure the execution time of a function in D?
Can the GC do it?
StopWatch and benchmark():
https://dlang.org/phobos/std_datetime.html
Ali
Hello, is there a tool to measure the execution time of a
function in D? Can the GC do it?
On Sunday, 27 December 2020 at 23:18:37 UTC, Rekel wrote:
Update;
Any clue why there's both "std.file" and "std.io.File"?
I was mostly unaware of the former.
The very first paragraph at the top of the `std.file`
documentation explains it:
"Functions in this module handle files as a unit, e.
It's more of a multi-part question,
I've been trying to read tuples using 'slurp', though later
realised one of the types was an enum, I'm guessing that's what
was the problem, which lead me down a whole rabbit hole.
- Can I directly read tuples using slurp? It doesnt seem to like
slurp!TUPLE
On 28.12.20 00:12, Rekel via Digitalmars-d-learn wrote:
is there a reason to use either 'splitter' or 'split'?
split gives you a newly allocated array with the results, splitter is lazy equivalent and doesn't
allocate. Feel free using either, doesn't matter much with these small puzzle inputs.
On 12/27/20 3:12 PM, Rekel wrote:
> is there a reason to use
> either 'splitter' or 'split'? I'm not sure I see why the difference
> would matter in the end.
splitter() is a lazy range algorithm. split() is a range algorithm as
well but it is eager; it will put the results in an array that it g
On Sunday, 27 December 2020 at 23:12:46 UTC, Rekel wrote:
Sidetangent, don't mean to bash the learning tour, as it's been
really useful for getting started, but I'm surprised stuff like
tuples and files arent mentioned there.
Update;
Any clue why there's both "std.file" and "std.io.File"?
I wa
On Sunday, 27 December 2020 at 13:27:49 UTC, oddp wrote:
foreach (group; readText("input").splitter("\n\n")) { ... }
Also, on other days, when the input is more uniform, there's
always https://dlang.org/library/std/file/slurp.html which
makes reading it in even easier, e.g. day02:
alias Rec
On Friday, 25 December 2020 at 20:59:03 UTC, vnr wrote:
Hello 😺
For a small "script" that generates printable files, I would
need to change the size of an image (which is loaded into
memory as an array of bytes) to shrink it to scale if it
exceeds the A4 page size.
To load the images into m
On Sunday, 27 December 2020 at 18:48:18 UTC, vnr wrote:
The one given at the beginning by Adam D. Ruppe was fine with
me,
fyi i think I am going to move that resize code from image.d to a
more independent imageresize.d or something. Same repo. Obviously
won't affect you if you already using i
On Sunday, 27 December 2020 at 16:49:49 UTC, Guillaume Piolat
wrote:
On Friday, 25 December 2020 at 20:59:03 UTC, vnr wrote:
Hello 😺
For a small "script" that generates printable files, I would
need to change the size of an image (which is loaded into
memory as an array of bytes) to shrink it
On Sunday, 27 December 2020 at 12:23:26 UTC, Max Samukha wrote:
Given a name bound to an alias sequence, what is a reliable way
to detect that?
import std.meta: AliasSeq;
alias a = AliasSeq!int;
static if () {
}
__traits(isSame, a, AliasSeq!a) could work but doesn't, because
it flattens si
On Sunday, 27 December 2020 at 17:49:10 UTC, BPS wrote:
void[] buff;
incommingConn.receive(buff);
this has no actual space to receive anything
void[] buff = ['a', 's', 'd', 'f'];
sock.send(buff);
sock.receive(buff);
and the return value needs to be ch
Hello, i want to create basic example of 2 apps which will be
exchanging data through socket connection. I have:
server
==
import std.stdio;
import std.string;
import std.socket;
void main()
{
auto sock = new Socket(AddressFamily.INET, SocketType.STREAM,
ProtocolType.IP);
sock.b
On Sunday, 27 December 2020 at 13:21:44 UTC, Rekel wrote:
On Sunday, 27 December 2020 at 02:41:12 UTC, Jesse Phillips
wrote:
Unfortunately std.csv is character based and not string.
https://dlang.org/phobos/std_csv.html#.csvReader
But your use case sounds like splitter is more aligned with
yo
On Friday, 25 December 2020 at 20:59:03 UTC, vnr wrote:
Hello 😺
For a small "script" that generates printable files, I would
need to change the size of an image (which is loaded into
memory as an array of bytes) to shrink it to scale if it
exceeds the A4 page size.
To load the images into m
On Sunday, 27 December 2020 at 14:40:01 UTC, Basile B. wrote:
A more concrete example of what you are trying to achieve would
allow to show the D way.
What happens with your code example for the struct:
```
struct S
{
ulong[] a;
@E(0) const int b=1;
void v() const {return;}
in
On Sunday, 27 December 2020 at 12:20:01 UTC, sighoya wrote:
On Sunday, 27 December 2020 at 04:13:53 UTC, Max Haughton wrote:
Not possible although implementing as a __trait would be about
15 lines I think.
I think that too, and it would nicely reuse the work of the
compiler to parse the who
On 27.12.20 01:13, Rekel via Digitalmars-d-learn wrote:
For context, I'm trying this with the puzzle input of day 6 of this year's advent of code.
(https://adventofcode.com/)
For that specific puzzle I simply did:
foreach (group; readText("input").splitter("\n\n")) { ... }
Since the input is
On Sunday, 27 December 2020 at 02:41:12 UTC, Jesse Phillips wrote:
Unfortunately std.csv is character based and not string.
https://dlang.org/phobos/std_csv.html#.csvReader
But your use case sounds like splitter is more aligned with
your needs.
https://dlang.org/phobos/std_algorithm_iteratio
bugreport filed https://issues.dlang.org/show_bug.cgi?id=21508
On
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=87915 I found in Issue 1441 there is PHP source code shown instead of the message. Must `
Given a name bound to an alias sequence, what is a reliable way
to detect that?
import std.meta: AliasSeq;
alias a = AliasSeq!int;
static if () {
}
__traits(isSame, a, AliasSeq!a) could work but doesn't, because
it flattens singletons, which means __traits(isSame, int,
AliasSeq!int) is tru
On Sunday, 27 December 2020 at 04:13:53 UTC, Max Haughton wrote:
Not possible although implementing as a __trait would be about
15 lines I think.
I think that too, and it would nicely reuse the work of the
compiler to parse the whole project.
I think read only AST access in some form would
On Saturday, 26 December 2020 at 21:45:41 UTC, Basile B. wrote:
struct E {int a;}
struct S
{
ulong[] a;
@E(0) const int b;
void v() const {}
void v(int) const {}
}
string getDeclaration(T)()
if (is(T == struct))
{
import std.traits, std.meta;
string result = "struct " ~ T
On Saturday, 26 December 2020 at 19:36:24 UTC, ag0aep6g wrote:
On 26.12.20 13:59, ag0aep6g wrote:
Looks like a pretty nasty bug somewhere in
std.experimental.allocator or (less likely) the GC. Further
reduced code:
[...]
Apparently, something calls deallocateAll on a Mallocator
28 matches
Mail list logo