Re: using std.algorithm to find intersection of DateTime[][] arg
On Wednesday, 9 September 2015 at 20:28:35 UTC, Laeeth Isharc wrote: so setIntersection(arg[0],arg[1],arg[2] .. arg[$-1]) except that I don't know how many series are in arg at compile time. what's the most efficient way to use Phobos to find these? (I could write a loop, but I am trying to learn how to use std.algorithm better). I'd use something like this, it works in O(Σ|arg[i]| * log|arg.length|) arg.nWayUnion.group.filter!(g => g[1] == arg.length).map!(g => g[0]).array
Re: What is the std.stream replacement?
On Monday, 20 July 2015 at 00:58:20 UTC, Charles Hixson wrote: I have DMD64 D Compiler v2.067.1 installed, and in the documentation of phobos what it says about std.stream is don't use it on new code. It doesn't, however, appear to offer any replacement. Certainly std.file, std.stdio, and std.path aren't replacements. So what *is* the appropriate replacement? More specificly, what should one use for binary i/o, particularly random access binary i/o? With fixed block size. There's none :( You can use std.stdio.File but it's not as flexible. This note in the documentation was there 3 years ago, and there's no replacement on the horizon, except some work in progress by Steven Schveighoffer (https://github.com/schveiguy/phobos/tree/new-io3)
How to strip struct/class invariants?
OK, so there was an old bug fixed in 2.067 (https://issues.dlang.org/show_bug.cgi?id=4421) so that now unions apparently can't contain a struct that has invariants. It kinda makes sense, although I don't see why the invariants can be simply ignored, as they don't have as much importance as destructors/postblits. But more to the point. I have a struct that has an invariant, and I wish to use it as a member of an union. With the latest compiler, I have to somehow remove the invariant. Is there some compile-time magic that I can use for this?
Re: How to strip struct/class invariants?
On Sunday, 5 July 2015 at 14:44:30 UTC, John Colvin wrote: struct A { ubyte[B.sizeof] mem; @property ref B b() { return *cast(B*)(mem.ptr); } mixin std.typecons.Proxy!b; } Thanks, I followed your suggestion and effectively rolled out my own union implementation. Ugly but it works. struct A { ubyte[maxSizeof] _data; @property ref T _as(T)() inout { return *cast(T*)(_data.ptr); } alias b = _as!uint; alias c = _as!size_t; alias d = _as!double; }
Re: What does dmd 2.066 want from me?
On Thursday, 8 January 2015 at 01:22:54 UTC, Rikki Cattermole wrote: Have you got opEqual's defined? Its wanting that and toHash I think. Yes, I have opEquals defined. I've just tried to add dummy toHash (returning a constant), but it doesn't help :( OK, it seems I'll have to stick with 2.065 and LDC 0.15. These new bugs in every new version of compiler drive me nuts. Thanks for trying to help, anyway.
What does dmd 2.066 want from me?
I'm trying to compile my software with the latest compiler, and it spits out the following error: $ make ... rdmd --force --build-only -IBioD -g -L-Lhtslib -L-l:libhts.a -L-l:libphobos2.a -ofbuild/sambamba.o main.d ... /tmp/.rdmd-1000/rdmd-main.d-5E103AD0DCA0998F00B4F9BA5B181EDE/objs/sambamba.o.o:(.data._D80TypeInfo_S3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamRead6__initZ+0x30): undefined reference to `_D3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamRead9__xtoHashFNbNeKxS3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamReadZm' /tmp/.rdmd-1000/rdmd-main.d-5E103AD0DCA0998F00B4F9BA5B181EDE/objs/sambamba.o.o:(.data._D80TypeInfo_S3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamRead6__initZ+0x38): undefined reference to `_D3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamRead11__xopEqualsFKxS3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamReadKxS3bio3bam4read41__T12EagerBamReadTS3bio3bam4read7BamReadZ12EagerBamReadZb' What the heck do these lines mean? Presumably they come from the recent change in hash implementation, but I don't use this struct in any dictionary whatsoever! It doesn't have opCmp either and perfectly worked until now.
Re: Segmentation fault after having a certain number of elements in an array?
On Saturday, 13 December 2014 at 09:24:51 UTC, Paul wrote: You are testing i against an ever-increasing limit aren't you, so it's an infinite loop. Read more carefully. samples is unmodified, it's m_samples whose length is changed.
Re: Segmentation fault after having a certain number of elements in an array?
On Saturday, 13 December 2014 at 08:59:19 UTC, Jeremy DeHaan wrote: I'll be trying to narrow it down even more tomorrow, but I was hoping somone here might have some insight into this weird issue I am having. Could you upload the code to somewhere? With only a small snippet, it's hard to get any clue.
printing array of strings with writefln?
writefln(%(%s-%), [a, b, c]) doesn't print the intended a-b-c but surrounds each string with double quotes - a-b-c, which I find inconsistent with the fact that writefln(%s, a string) prints the string without any quotes. How do I get the desired behaviour using just the format string?
Re: printing array of strings with writefln?
Thanks! The Ali's book is indeed superb, covering even such minor details.
Re: std.parallelism curious results
Welcome to the world of multithreading. You have just discovered that atomic operations are performance killers, congratulations on this.
Re: Large binary size using std.regex
On Sunday, 24 August 2014 at 03:14:33 UTC, ketmar via Digitalmars-d-learn wrote: yes. this binary includes statically linked runtime and phobos, plus alot of template expansions. alas, template magic is not free. OTOH, on Linux latest LDC does far better job in eliminating dead code than DMD: $ ldc2 -O -release test.d ls -l test | cut -f 5- -d ' ' 712522 Aug 24 10:07 test $ dmd -O -release -noboundscheck test.d ls -l test | cut -f 5- -d ' ' 1892622 Aug 24 10:07 test Which means there's plenty of unfulfilled potential.
Re: Large binary size using std.regex
On Sunday, 24 August 2014 at 06:20:38 UTC, ketmar via Digitalmars-d-learn wrote: does ldc uses shared runtime here? No, it doesn't: $ ldd test linux-vdso.so.1 (0x7fffce266000) librt.so.1 = /usr/lib/librt.so.1 (0x7fc174193000) libdl.so.2 = /usr/lib/libdl.so.2 (0x7fc173f8f000) libpthread.so.0 = /usr/lib/libpthread.so.0 (0x7fc173d71000) libm.so.6 = /usr/lib/libm.so.6 (0x7fc173a6d000) libgcc_s.so.1 = /usr/lib/libgcc_s.so.1 (0x7fc173857000) libc.so.6 = /usr/lib/libc.so.6 (0x7fc1734a9000) /lib64/ld-linux-x86-64.so.2 (0x7fc17439b000)