Re: Read a unicode character from the terminal

2012-04-04 Thread Jacob Carlborg
On 2012-04-05 01:21, Stewart Gordon wrote: On 04/04/2012 17:37, Jacob Carlborg wrote: Sure I can help you with testing. I have a lot on my own table so I don't have any time for implementing things (maybe some small things). If I may ask, what is the point of this library? Just to hold some m

Re: Binary Heap Errors Class level vs function level

2012-04-04 Thread Chris Pons
Thank you! That helps out quite a bit. On Thursday, 5 April 2012 at 01:28:12 UTC, Ali Çehreli wrote: On 04/04/2012 05:24 PM, Chris Pons wrote: > I'm still messing around with binary heaps. I've successfully created > and used it on the function level but for some reason when I move it to > the

Re: Binary Heap Errors Class level vs function level

2012-04-04 Thread Ali Çehreli
On 04/04/2012 05:24 PM, Chris Pons wrote: > I'm still messing around with binary heaps. I've successfully created > and used it on the function level but for some reason when I move it to > the class level I get an error. Furthermore, i'm not entirely sure how > to use a binary heap without auto

Binary Heap Errors Class level vs function level

2012-04-04 Thread Chris Pons
I'm still messing around with binary heaps. I've successfully created and used it on the function level but for some reason when I move it to the class level I get an error. Furthermore, i'm not entirely sure how to use a binary heap without auto as the type. class AStar { ReferenceNode[] ope

Re: Read a unicode character from the terminal

2012-04-04 Thread Stewart Gordon
On 04/04/2012 17:37, Jacob Carlborg wrote: Sure I can help you with testing. I have a lot on my own table so I don't have any time for implementing things (maybe some small things). If I may ask, what is the point of this library? Just to hold some miscellaneous utility classes/structs/funct

Re: Insert an element into an Associative Array ?

2012-04-04 Thread Chris Pons
Ok, thanks for the help, much appreciated. On Wednesday, 4 April 2012 at 19:57:40 UTC, ixid wrote: Oops, the comment should read as follows, and test[bool] should not be on the next line. //Conceptually maybe clearer as Node[] test[bool]

Re: Insert an element into an Associative Array ?

2012-04-04 Thread ixid
Oops, the comment should read as follows, and test[bool] should not be on the next line. //Conceptually maybe clearer as Node[] test[bool]

Re: Insert an element into an Associative Array ?

2012-04-04 Thread ixid
You're trying to append to something that's not an array, you haven't set the value part to be an array so you're doing doing the same as: int a; a ~= 5; which obviously doesn't work. If you want to append to an associative array create it like this: Node[][bool] test; //Conceptually maybe

Re: parallel unzip in progress

2012-04-04 Thread Jay Norwood
On Wednesday, 4 April 2012 at 07:39:56 UTC, Jay Norwood wrote: On Wednesday, 4 April 2012 at 07:25:25 UTC, dennis luehring I decided to try the option where the data is stored in the zip file uncompressed. Since the folder is just over 2GB, I ran into the stdio File problems with being unabl

Re: Insert an element into an Associative Array ?

2012-04-04 Thread Jacob Carlborg
On 2012-04-04 20:57, Chris Pons wrote: I'm playing around with associative arrays right now and I can't seem to figure out how to add additional objects to the array. I tried insert but it doesn't recognize both arguments. Also, if I do this it produces an error: Node[bool] test; Node node; N

Re: Questions about the slice operator

2012-04-04 Thread Jacob Carlborg
On 2012-04-04 19:09, Jonathan M Davis wrote: That might work, but it does make it so that ".." has very different meanings in different contexts, and I don't know that it really buys us much. iota already does them same thing (and with more functionality), just without the syntactic sugar. Also,

Re: Insert an element into an Associative Array ?

2012-04-04 Thread H. S. Teoh
On Wed, Apr 04, 2012 at 08:57:54PM +0200, Chris Pons wrote: > I'm playing around with associative arrays right now and I can't > seem to figure out how to add additional objects to the array. I > tried insert but it doesn't recognize both arguments. > > Also, if I do this it produces an error: >

Insert an element into an Associative Array ?

2012-04-04 Thread Chris Pons
I'm playing around with associative arrays right now and I can't seem to figure out how to add additional objects to the array. I tried insert but it doesn't recognize both arguments. Also, if I do this it produces an error: Node[bool] test; Node node; Node[bool] temp = [ false:node ]; test ~

Re: log2 buggy or is a real thing?

2012-04-04 Thread Don Clugston
On 04/04/12 13:46, bearophile wrote: Do you know why is this program: import std.stdio; void main() { real r = 9223372036854775808UL; writefln("%1.19f", r); } Printing: 9223372036854775807.800 Instead of this? 9223372036854775808.000 Bye, bearophile

Re: log2 buggy or is a real thing?

2012-04-04 Thread Don Clugston
On 04/04/12 18:53, Timon Gehr wrote: On 04/04/2012 05:15 PM, Don Clugston wrote: I don't think so. For 80-bit reals, every long can be represented exactly in an 80 bit real, as can every ulong from 0 up to and including ulong.max - 1. The only non-representable built-in integer is ulong.max, wh

Re: log2 buggy or is a real thing?

2012-04-04 Thread Timon Gehr
On 04/04/2012 01:46 PM, bearophile wrote: Do you know why is this program: import std.stdio; void main() { real r = 9223372036854775808UL; writefln("%1.19f", r); } Printing: 9223372036854775807.800 Instead of this? 9223372036854775808.000 Bye, bearoph

Re: Questions about the slice operator

2012-04-04 Thread Jonathan M Davis
On Wednesday, April 04, 2012 14:37:54 Simen Kjærås wrote: > On Wed, 04 Apr 2012 14:21:01 +0200, Jacob Carlborg wrote: > > On 2012-04-04 14:16, Simen Kjærås wrote: > >> And what do we do with 3..$? > > > > Hmm, that's a good point. The best I can think of for now is to > > translate that to: > >

Re: Questions about the slice operator

2012-04-04 Thread Jonathan M Davis
On Wednesday, April 04, 2012 12:06:33 Jacob Carlborg wrote: > On 2012-04-04 04:11, Jonathan M Davis wrote: > > foreach(i; 0 .. 5) > > > > is more efficient only because it has _nothing_ to do with arrays. > > Generalizing the syntax wouldn't help at all, and if it were generalized, > > it would ar

Re: log2 buggy or is a real thing?

2012-04-04 Thread Timon Gehr
On 04/04/2012 05:15 PM, Don Clugston wrote: I don't think so. For 80-bit reals, every long can be represented exactly in an 80 bit real, as can every ulong from 0 up to and including ulong.max - 1. The only non-representable built-in integer is ulong.max, which (depending on rounding mode) gets

Re: Read a unicode character from the terminal

2012-04-04 Thread Jacob Carlborg
On 2012-04-04 18:06, Stewart Gordon wrote: The D2 version is now up on the site. Jacob - would you be up for helping me with testing/implementation of my library on Mac OS? If you do a search for "todo" you'll see what needs to be done. Some of it will benefit Unix-type systems generally. If pe

Re: Read a unicode character from the terminal

2012-04-04 Thread Stewart Gordon
On 31/03/2012 23:14, Stewart Gordon wrote: You might want to try the console module in my utility library: http://pr.stewartsplace.org.uk/d/sutil/ (For D1 at the moment, but a D2 version will be available any day now!) The D2 version is now up on the site. Jacob - would you be up for helpin

Re: log2 buggy or is a real thing?

2012-04-04 Thread Don Clugston
On 04/04/12 13:40, bearophile wrote: Jonathan M Davis: This progam: import std.math; import std.stdio; import std.typetuple; ulong log2(ulong n) { return n == 1 ? 0 : 1 + log2(n / 2); } void print(ulong value) { writefln("%s: %s %s", value, log2(value), std.math.

Re: Read a unicode character from the terminal

2012-04-04 Thread Jacob Carlborg
On 2012-03-31 17:56, Jacob Carlborg wrote: How would I read a unicode character from the terminal? I've tried using "std.cstream.din.getc" but it seems to only work for ascii characters. If I try to read and print something that isn't ascii, it just prints a question mark. I solved it like this

Re: Questions about the slice operator

2012-04-04 Thread Jacob Carlborg
On 2012-04-04 16:40, Simen Kjærås wrote: It's quite simple, really - an index set holds indices. For a regular array of N elements, the index set it [0..N-1]. For an AA, the index set is all the keys in the AA. Basically, an index set is the set of all values that will give meaningful results fro

Re: Questions about the slice operator

2012-04-04 Thread Simen Kjærås
On Wed, 04 Apr 2012 15:29:58 +0200, Jacob Carlborg wrote: On 2012-04-04 15:01, Simen Kjærås wrote: Actually, I've thought a little about this. And apart from the tiny idiosyncrasy of $, a..b as a more regular type can bring some interesting enhancements to the language. Consider a..b as simp

Re: HelloWordl in Webserver

2012-04-04 Thread Dmitry Olshansky
Not, I receive the error: $ gdmd-4.6 server.d cgi.d -version=embedded_httpd std.algorithm.indexOf has been scheduled for deprecation. You may want to use std.algorithm.countUntil instead. Oh my, indexOf was deprecated? News to me. cgi.d:2231: Error: undefined identifier lastSocketError -

Re: HelloWordl in Webserver

2012-04-04 Thread Adam D. Ruppe
On Wednesday, 4 April 2012 at 08:04:14 UTC, Xan wrote: Not, I receive the error: What version of D is that? lastSocketError is in phobos: http://dlang.org/phobos/std_socket.html#lastSocketError and it should work in windows and linux. Maybe your compiler is old.

Re: Questions about the slice operator

2012-04-04 Thread Jacob Carlborg
On 2012-04-04 15:01, Simen Kjærås wrote: Actually, I've thought a little about this. And apart from the tiny idiosyncrasy of $, a..b as a more regular type can bring some interesting enhancements to the language. Consider a..b as simply a set of indices, defined by a start point and an end poin

Re: Questions about the slice operator

2012-04-04 Thread Simen Kjærås
On Wed, 04 Apr 2012 14:16:54 +0200, Simen Kjærås wrote: On Wed, 04 Apr 2012 12:06:33 +0200, Jacob Carlborg wrote: On 2012-04-04 04:11, Jonathan M Davis wrote: foreach(i; 0 .. 5) is more efficient only because it has _nothing_ to do with arrays. Generalizing the syntax wouldn't help at

Re: Questions about the slice operator

2012-04-04 Thread Simen Kjærås
On Wed, 04 Apr 2012 14:21:01 +0200, Jacob Carlborg wrote: On 2012-04-04 14:16, Simen Kjærås wrote: And what do we do with 3..$? Hmm, that's a good point. The best I can think of for now is to translate that to: range(3, size_t.max) Or something like: struct range { size_t start;

Re: Questions about the slice operator

2012-04-04 Thread Jacob Carlborg
On 2012-04-04 14:16, Simen Kjærås wrote: And what do we do with 3..$? Hmm, that's a good point. The best I can think of for now is to translate that to: range(3, size_t.max) Or something like: struct range { size_t start; size_t end; bool dollar; // better name is needed } ra

Re: Questions about the slice operator

2012-04-04 Thread Simen Kjærås
On Wed, 04 Apr 2012 12:06:33 +0200, Jacob Carlborg wrote: On 2012-04-04 04:11, Jonathan M Davis wrote: foreach(i; 0 .. 5) is more efficient only because it has _nothing_ to do with arrays. Generalizing the syntax wouldn't help at all, and if it were generalized, it would arguably have t

Re: log2 buggy or is a real thing?

2012-04-04 Thread bearophile
Do you know why is this program: import std.stdio; void main() { real r = 9223372036854775808UL; writefln("%1.19f", r); } Printing: 9223372036854775807.800 Instead of this? 9223372036854775808.000 Bye, bearophile

Re: log2 buggy or is a real thing?

2012-04-04 Thread bearophile
Jonathan M Davis: > This progam: > > import std.math; > import std.stdio; > import std.typetuple; > > ulong log2(ulong n) > { > return n == 1 ? 0 > : 1 + log2(n / 2); > } > > void print(ulong value) > { > writefln("%s: %s %s", value, log2(value), std.math.log2(value));

Re: Equivalents to policy classes in D

2012-04-04 Thread Joseph Rushton Wakeling
Thanks to all for the useful suggestions here. I'll have a play with the ideas suggested and come back if problems arise ... :-)

Re: Questions about the slice operator

2012-04-04 Thread Jacob Carlborg
On 2012-04-04 04:11, Jonathan M Davis wrote: foreach(i; 0 .. 5) is more efficient only because it has _nothing_ to do with arrays. Generalizing the syntax wouldn't help at all, and if it were generalized, it would arguably have to be consistent in all of its uses, in which case foreach(i; 0 ..

log2 buggy or is a real thing?

2012-04-04 Thread Jonathan M Davis
This progam: import std.math; import std.stdio; import std.typetuple; ulong log2(ulong n) { return n == 1 ? 0 : 1 + log2(n / 2); } void print(ulong value) { writefln("%s: %s %s", value, log2(value), std.math.log2(value)); } void main() { foreach(T; TypeTuple!(byte,

Re: HelloWordl in Webserver

2012-04-04 Thread Xan
On Tuesday, 3 April 2012 at 13:33:19 UTC, Adam D. Ruppe wrote: On Tuesday, 3 April 2012 at 08:42:01 UTC, Xan wrote: I receive errors: I changed some stuff since the beginning of thi thread. cgi.d now includes a http server without needing the other modules. So if you just get the new cgi.d,

Re: parallel unzip in progress

2012-04-04 Thread Jay Norwood
On Wednesday, 4 April 2012 at 07:25:25 UTC, dennis luehring wrote: Am 04.04.2012 08:31, schrieb Jay Norwood: This particular loop is currently excluding restore of times on directory entries, but I suppose I can restore the directory times after all the files have been expanded into the director

Re: parallel unzip in progress

2012-04-04 Thread dennis luehring
Am 04.04.2012 08:31, schrieb Jay Norwood: On Tuesday, 3 April 2012 at 05:27:08 UTC, Jay Norwood wrote: .. So, to answer my own questions ... I placed the code below in a taskpool parallel foreach loop, where each am is an archive member. It is expanded, and the expanded data is written