Ranges usages

2012-11-21 Thread bearophile
(This is a partial repost from D.learn.) Some time ago after Andrei Alexandrescu talk "Iterators must Go" someone asked about implementing the Dutch national flag sort algorithm with D ranges. This is a version of mine (but unfortunately currently I can't try it on the Dlist of Phobos), it lo

Re: Ranges usages

2012-11-21 Thread Rob T
FYI I'm getting these compile errors, must be the compiler flags I'm using? source/main.d(19): Error: cannot implicitly convert expression (dictionary.length() - 1LU) of type ulong to int source/main.d(48): Error: cannot implicitly convert expression (dictionary.length() - 1LU) of type ulong

Re: Ranges usages

2012-11-22 Thread monarch_dodra
On Thursday, 22 November 2012 at 01:14:23 UTC, bearophile wrote: [SNIP] Thank you, bye, bearophile I'd argue that your first "compress1" isn't range correct either anyways, because "w ~ ch;" (which will allocate) is not part of the range interface. Neither is "w = [ch];" (which will also

Re: Ranges usages

2012-11-22 Thread monarch_dodra
On Thursday, 22 November 2012 at 06:52:55 UTC, Rob T wrote: FYI I'm getting these compile errors, must be the compiler flags I'm using? Must be that bearophile and I are on windows (ergo 32), so "length" is of type "size_t", which is a "uint". This matches the key of the dictionary. If yo

Re: Ranges usages

2012-11-22 Thread Artur Skawina
On 11/22/12 02:14, bearophile wrote: > In the following program there are two versions of the compress function, > that implement the same bare-bones version of the LZW > (http://en.wikipedia.org/wiki/Lempel-Ziv-Welch ) compression algorithm. > > compress1 is the simpler version, while compress2

Re: Ranges usages

2012-11-22 Thread Timon Gehr
On 11/22/2012 11:25 AM, monarch_dodra wrote: On Thursday, 22 November 2012 at 06:52:55 UTC, Rob T wrote: FYI I'm getting these compile errors, must be the compiler flags I'm using? Must be that bearophile and I are on windows (ergo 32), so "length" is of type "size_t", which is a "uint". This

Re: Ranges usages

2012-11-22 Thread Jonathan M Davis
On Friday, November 23, 2012 01:52:51 Timon Gehr wrote: > On 11/22/2012 11:25 AM, monarch_dodra wrote: > > On Thursday, 22 November 2012 at 06:52:55 UTC, Rob T wrote: > >> FYI > >> > >> I'm getting these compile errors, must be the compiler flags I'm using? > > > > Must be that bearophile and I a

Re: Ranges usages

2012-11-23 Thread Timon Gehr
On 11/23/2012 03:01 AM, Jonathan M Davis wrote: On Friday, November 23, 2012 01:52:51 Timon Gehr wrote: On 11/22/2012 11:25 AM, monarch_dodra wrote: On Thursday, 22 November 2012 at 06:52:55 UTC, Rob T wrote: FYI I'm getting these compile errors, must be the compiler flags I'm using? Must b