Re: drop* and take* only for specific element values

2014-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, 13 August 2014 at 21:22:31 UTC, Nordlöw wrote: return range.find(a => a != element); What have I done wrong? You forgot the !, making the predicate a function argument. It should be return range.find!(a => a != element); - Jonathan M Davis

Re: drop* and take* only for specific element values

2014-08-13 Thread Nordlöw
On Wednesday, 13 August 2014 at 21:22:31 UTC, Nordlöw wrote: unittest { dln([1, 2, 3].dropWhile(1)); } should be unittest { [1, 2, 3].dropWhile(1) == [2, 3]; }

Re: drop* and take* only for specific element values

2014-08-13 Thread Nordlöw
On Wednesday, 13 August 2014 at 14:45:43 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: They're called find and until. You just have to give them the opposite predicate that you'd give a function called dropIf or takeIf. Ok, thx. As an exercise I tried auto dropWhile(R, E)(R range, E e

Re: LuaD + VisualD link issue

2014-08-13 Thread Jesse Phillips via Digitalmars-d-learn
On Tuesday, 12 August 2014 at 22:25:24 UTC, Johnathan Sunders wrote: I'm having an issue with building programs that link with LuaD using VisualD. If I use Dub, it builds without an issue, but generating a project file and compiling it through VisualD results in "Error 162: Bad Type Index refer

Re: Linked list as a bidirectional range? I have some questions...

2014-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 13, 2014 at 08:52:32PM +, via Digitalmars-d-learn wrote: > On Wednesday, 13 August 2014 at 20:27:29 UTC, H. S. Teoh via > Digitalmars-d-learn wrote: > >On Wed, Aug 13, 2014 at 07:58:49PM +, Gary Willoughby via > >Digitalmars-d-learn wrote: > >>On Wednesday, 13 August 2014 at 19:

Re: Linked list as a bidirectional range? I have some questions...

2014-08-13 Thread via Digitalmars-d-learn
On Wednesday, 13 August 2014 at 20:27:29 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Wed, Aug 13, 2014 at 07:58:49PM +, Gary Willoughby via Digitalmars-d-learn wrote: On Wednesday, 13 August 2014 at 19:43:20 UTC, H. S. Teoh via Digitalmars-d-learn wrote: >On Wed, Aug 13, 2014 at 07:37:

Re: Linked list as a bidirectional range? I have some questions...

2014-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 13, 2014 at 07:58:49PM +, Gary Willoughby via Digitalmars-d-learn wrote: > On Wednesday, 13 August 2014 at 19:43:20 UTC, H. S. Teoh via > Digitalmars-d-learn wrote: > >On Wed, Aug 13, 2014 at 07:37:09PM +, Gary Willoughby via > >Digitalmars-d-learn wrote: > >>On Wednesday, 13 A

Re: Linked list as a bidirectional range? I have some questions...

2014-08-13 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 13 August 2014 at 19:43:20 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Wed, Aug 13, 2014 at 07:37:09PM +, Gary Willoughby via Digitalmars-d-learn wrote: On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via Digitalmars-d-learn wrote: >On Wed, Aug 13, 2014 at 06:31:

Re: Linked list as a bidirectional range? I have some questions...

2014-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 13, 2014 at 07:37:09PM +, Gary Willoughby via Digitalmars-d-learn wrote: > On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via > Digitalmars-d-learn wrote: > >On Wed, Aug 13, 2014 at 06:31:32PM +, Gary Willoughby via > >Digitalmars-d-learn wrote: [...] > >>I've used yo

Re: Linked list as a bidirectional range? I have some questions...

2014-08-13 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Wed, Aug 13, 2014 at 06:31:32PM +, Gary Willoughby via Digitalmars-d-learn wrote: On Monday, 11 August 2014 at 20:02:38 UTC, H. S. Teoh via Digitalmars-d-learn wrote: >Anyway, clearly we're not underst

Re: Linked list as a bidirectional range? I have some questions...

2014-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 13, 2014 at 07:23:30PM +, via Digitalmars-d-learn wrote: > On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via > Digitalmars-d-learn wrote: > >On Wed, Aug 13, 2014 at 06:31:32PM +, Gary Willoughby via > >Digitalmars-d-learn wrote: [...] > >>I've used your advice and imp

Re: Linked list as a bidirectional range? I have some questions...

2014-08-13 Thread via Digitalmars-d-learn
On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Wed, Aug 13, 2014 at 06:31:32PM +, Gary Willoughby via Digitalmars-d-learn wrote: On Monday, 11 August 2014 at 20:02:38 UTC, H. S. Teoh via Digitalmars-d-learn wrote: >Anyway, clearly we're not underst

Re: Linked list as a bidirectional range? I have some questions...

2014-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 13, 2014 at 06:31:32PM +, Gary Willoughby via Digitalmars-d-learn wrote: > On Monday, 11 August 2014 at 20:02:38 UTC, H. S. Teoh via > Digitalmars-d-learn wrote: > >Anyway, clearly we're not understanding each other, so let me present > >some concrete code so that we aren't just ta

Re: Linked list as a bidirectional range? I have some questions...

2014-08-13 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 11 August 2014 at 20:02:38 UTC, H. S. Teoh via Digitalmars-d-learn wrote: Anyway, clearly we're not understanding each other, so let me present some concrete code so that we aren't just talking past each other: I've used your advice and implemented a range over the list as suggeste

Re: Emacs d-mode cannot handle backquoted backslashe

2014-08-13 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2014-08-12 at 23:53 +0100, Russel Winder wrote: […] > Per Nordlöw has offered a putative fix via a pull request. I'll check > out the claim and if it seems to be true (and I fully expect it to be > so) I'll accept the pull request. People using MELPA should see the new > package quite quick

Re: drop* and take* only for specific element values

2014-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 13 Aug 2014 07:45:17 -0700 Jonathan M Davis via Digitalmars-d-learn wrote: > On Wed, 13 Aug 2014 14:28:29 + > Meta via Digitalmars-d-learn > wrote: > > > On Wednesday, 13 August 2014 at 12:37:34 UTC, Nordlöw wrote: > > > Are there variants of drop* and take* that only drop element if

Re: safe pure unittest

2014-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 13, 2014 at 03:03:14PM +0200, simendsjo via Digitalmars-d-learn wrote: > On 08/13/2014 02:50 PM, Dicebot wrote: > > On Wednesday, 13 August 2014 at 12:26:02 UTC, simendsjo wrote: > >> This is the first time I've seen attributes on unittests: > >> https://github.com/D-Programming-Langua

Re: drop* and take* only for specific element values

2014-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 13 Aug 2014 14:28:29 + Meta via Digitalmars-d-learn wrote: > On Wednesday, 13 August 2014 at 12:37:34 UTC, Nordlöw wrote: > > Are there variants of drop* and take* that only drop element if > > its equal to a value kind of like strip does? > > > > If not I believe they should be added

Re: drop* and take* only for specific element values

2014-08-13 Thread Meta via Digitalmars-d-learn
On Wednesday, 13 August 2014 at 12:37:34 UTC, Nordlöw wrote: Are there variants of drop* and take* that only drop element if its equal to a value kind of like strip does? If not I believe they should be added. No, but it'd probably be useful. Maybe call them dropIf/takeIf, or just add an ove

Re: safe pure unittest

2014-08-13 Thread simendsjo via Digitalmars-d-learn
On 08/13/2014 02:50 PM, Dicebot wrote: > On Wednesday, 13 August 2014 at 12:26:02 UTC, simendsjo wrote: >> This is the first time I've seen attributes on unittests: >> https://github.com/D-Programming-Language/phobos/pull/2349/files#diff-ba05e420ac1da65db044e79304d641b6R179 >> >> >> Has this always

Re: safe pure unittest

2014-08-13 Thread Dicebot via Digitalmars-d-learn
On Wednesday, 13 August 2014 at 12:26:02 UTC, simendsjo wrote: This is the first time I've seen attributes on unittests: https://github.com/D-Programming-Language/phobos/pull/2349/files#diff-ba05e420ac1da65db044e79304d641b6R179 Has this always been supported? I guess it's good practice to add t

drop* and take* only for specific element values

2014-08-13 Thread Nordlöw
Are there variants of drop* and take* that only drop element if its equal to a value kind of like strip does? If not I believe they should be added.

safe pure unittest

2014-08-13 Thread simendsjo via Digitalmars-d-learn
This is the first time I've seen attributes on unittests: https://github.com/D-Programming-Language/phobos/pull/2349/files#diff-ba05e420ac1da65db044e79304d641b6R179 Has this always been supported? I guess it's good practice to add these on unittests too, but does people even know about this featur

Re: Separate Printing Mantissa and Exponent of a Floating Point

2014-08-13 Thread Nordlöw
On Wednesday, 13 August 2014 at 07:58:40 UTC, Nordlöw wrote: { float x = 1.23e10; auto y = *cast(FloatRep*)(&x); writeln(y.fraction, ", ", y.exponent, ", ", y.sign); } { double x = 1.23e10; auto y = *cast(DoubleR

Re: Separate Printing Mantissa and Exponent of a Floating Point

2014-08-13 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 13 August 2014 at 07:51:30 UTC, Nordlöw wrote: Could someone briefly outline the algorithm that converts the fraction part of FloatRep into a string in base 10? Walter Bright broke down the Floating point to explain how it works and why as i recall.. http://dlang.org/d-floati

Re: Separate Printing Mantissa and Exponent of a Floating Point

2014-08-13 Thread Nordlöw
On Wednesday, 13 August 2014 at 07:51:30 UTC, Nordlöw wrote: 1. http://dlang.org/phobos/std_bitmanip.html#.FloatRep Can somebody shortly explain why import std.stdio, std.algorithm, std.range, std.stdio, std.bitmanip; void main(string args[]) { { float x = 1.23e10; auto

Re: Separate Printing Mantissa and Exponent of a Floating Point

2014-08-13 Thread Nordlöw
On Monday, 11 August 2014 at 15:30:30 UTC, Justin Whear wrote: 1. http://dlang.org/phobos/std_bitmanip.html#.FloatRep Could someone briefly outline the algorithm that converts the fraction part of FloatRep into a string in base 10? My first guess is sum = 0; foreach (bit_index i, bit_value