The book "Programming in D" is in beta

2011-11-13 Thread Ali Çehreli
I have been translating my Turkish D book "D Programlama Dili" to English under the title "Programming in D". I have decided to make its current state available online: http://ddili.org/ders/d.en/index.html I will make more chapters available as they get translated. As the book is for the n

Re: Creating a growable binary heap or priority queue using Phobos?

2011-11-13 Thread SimonM
On 2011/11/14 02:10 AM, bearophile wrote: SimonM: 2009, 27 April: http://www.digitalmars.com/d/archives/digitalmars/D/std.algorithm.BinaryHeap_88811.html See the working version: http://rosettacode.org/wiki/Huffman_coding#D Bye, bearophile Okay, I looked at the example, and it seems that t

Re: Creating a growable binary heap or priority queue using Phobos?

2011-11-13 Thread SimonM
On 2011/11/14 01:55 AM, Jonathan M Davis wrote: On Monday, November 14, 2011 01:25:58 SimonM wrote: What am I doing wrong? I don't know. I've never used BinaryHeap. I'd have to study it. I just noticed that you were trying to use treat Array as a range, which isn't going to work (regardless of

Re: Mutable enums

2011-11-13 Thread Jonathan M Davis
On Monday, November 14, 2011 04:03:54 so wrote: > Trying to remember the discussions on digitalmars.D regarding > enum/immutable. There were contradicting opinions. > You ask the same question at two different times, you get at least two > different answers, especially on this matter. > There was/i

Re: Mutable enums

2011-11-13 Thread so
On Mon, 14 Nov 2011 02:50:50 +0200, Jonathan M Davis wrote: No. Those are two _very_ different things. immutable a = [3, 1, 2]; creates a variable of type immutable(int[]). You takes up memory. You can take its address - e.g. &a. It exists even if you don't use it at all. enum a = [3, 1

Re: Mutable enums

2011-11-13 Thread Jonathan M Davis
On Monday, November 14, 2011 02:16:57 so wrote: > On Mon, 14 Nov 2011 02:09:40 +0200, Jonathan M Davis > > wrote: > > It depends entirely on what you're trying to do. If you understand how > > manifest constants work, then they can be quite advantageous. What you > > probably really want for arra

Re: Mutable enums

2011-11-13 Thread so
On Mon, 14 Nov 2011 02:09:40 +0200, Jonathan M Davis wrote: It depends entirely on what you're trying to do. If you understand how manifest constants work, then they can be quite advantageous. What you probably really want for arrays though is not an enum but just a const or immutable module

Re: Creating a growable binary heap or priority queue using Phobos?

2011-11-13 Thread bearophile
SimonM: > 2009, 27 April: > http://www.digitalmars.com/d/archives/digitalmars/D/std.algorithm.BinaryHeap_88811.html See the working version: http://rosettacode.org/wiki/Huffman_coding#D Bye, bearophile

Re: Mutable enums

2011-11-13 Thread Jonathan M Davis
On Sunday, November 13, 2011 19:02:01 bearophile wrote: > Jonathan M Davis: > > > import std.algorithm; > > > void main() { > > > > > > enum a = [3, 1, 2]; > > > enum s = sort(a); > > > assert(equal(a, [3, 1, 2])); > > > assert(equal(s, [1, 2, 3])); > > > > > > } > > > > It's not

Re: Mutable enums

2011-11-13 Thread bearophile
Jonathan M Davis: > > import std.algorithm; > > void main() { > > enum a = [3, 1, 2]; > > enum s = sort(a); > > assert(equal(a, [3, 1, 2])); > > assert(equal(s, [1, 2, 3])); > > } > > It's not a bug. Those an manifest constants. They're copy-pasted into > whatever > code you use

Re: Creating a growable binary heap or priority queue using Phobos?

2011-11-13 Thread Jonathan M Davis
On Monday, November 14, 2011 01:25:58 SimonM wrote: > What am I doing wrong? I don't know. I've never used BinaryHeap. I'd have to study it. I just noticed that you were trying to use treat Array as a range, which isn't going to work (regardless of whatever BinaryHeap does), so I tried to help y

Re: Creating a growable binary heap or priority queue using Phobos?

2011-11-13 Thread SimonM
On 2011/11/13 23:22 PM, Jonathan M Davis wrote: On Sunday, November 13, 2011 23:12:30 SimonM wrote: Okay, I might on the wrong track, but part of the reason that the isRandomAccessRange template fails might be because, while Array!(T) internally uses a Range, it doesn't itself actually provide t

Re: Mutable enums

2011-11-13 Thread Jonathan M Davis
On Sunday, November 13, 2011 17:54:14 bearophile wrote: > Do you remember if this bug is in Bugzilla? > > > import std.algorithm; > void main() { > enum a = [3, 1, 2]; > enum s = sort(a); > assert(equal(a, [3, 1, 2])); > assert(equal(s, [1, 2, 3])); > } It's not a bug. Those an m

Mutable enums

2011-11-13 Thread bearophile
Do you remember if this bug is in Bugzilla? import std.algorithm; void main() { enum a = [3, 1, 2]; enum s = sort(a); assert(equal(a, [3, 1, 2])); assert(equal(s, [1, 2, 3])); } Bye, bearophile

Re: Creating a growable binary heap or priority queue using Phobos?

2011-11-13 Thread Jonathan M Davis
On Sunday, November 13, 2011 23:12:30 SimonM wrote: > Okay, I might on the wrong track, but part of the reason that the > isRandomAccessRange template fails might be because, while Array!(T) > internally uses a Range, it doesn't itself actually provide the save() > and popBack() functions that a Ra

Re: Creating a growable binary heap or priority queue using Phobos?

2011-11-13 Thread SimonM
On 2011/11/13 22:49 PM, SimonM wrote: Hey, I'm trying to use the BinaryHeap in Phobos, but somehow can't get it working with the Array!(T) container so that the heap can actually be growable. I keep getting this error: Error: template instance BinaryHeap!(myArray,"a > b") does not match template

Creating a growable binary heap or priority queue using Phobos?

2011-11-13 Thread SimonM
Hey, I'm trying to use the BinaryHeap in Phobos, but somehow can't get it working with the Array!(T) container so that the heap can actually be growable. I keep getting this error: Error: template instance BinaryHeap!(myArray,"a > b") does not match template declaration BinaryHeap(Store,alias