Re: Custom Exponents

2013-12-14 Thread Nathan M. Swan
On 12/14/13 8:22 PM, Malkierian wrote: Alright, so I'm trying to do hex string to integer conversion, but I can't for the live of me find how to do exponent calculation in D. Java has a Math.pow() function that allows you to specify the base and the exponent, but all I've seen in D's libraries a

Re: How do you guys debug large programs?

2013-05-28 Thread Nathan M. Swan
On Monday, 27 May 2013 at 19:55:57 UTC, Gary Willoughby wrote: This is quite an open ended question but i wondered how you guys debug your D programs (i'm talking about stepping through code, setting breakpoints, etc). The lack of nice IDE's with integrated debuggers is worrying when working wi

Re: Operator overloading question

2013-01-20 Thread Nathan M. Swan
On Monday, 21 January 2013 at 06:19:47 UTC, Joseph Cassman wrote: Please refer to http://dpaste.dzfl.pl/edit/b73ef2cd The code is contrived but is trying to focus on overloading the "+" and "*" operators for a struct. Here is the output. /home/c215/c527.d(36): Error: incompatible types for (

Re: parallel() and random number generation

2013-01-15 Thread Nathan M. Swan
On Monday, 14 January 2013 at 22:24:22 UTC, Joseph Rushton Wakeling wrote: Hello all, One of the claims made for pseudo-random number generation in D is that rndGen (default RNG) is thread-safe, that is, each instance is unique to its thread and is seeded with unpredictableSeed, which should

Re: MS ODBC encoding issue

2012-12-04 Thread Nathan M. Swan
On Tuesday, 4 December 2012 at 07:59:40 UTC, Sam Hu wrote: Greetings! Any help would be much appreicated in advance as I've really struggled for quite long time! I wrote a class wrapper for MS ODBC Access database.When I try to run query on an Access database file,all fields contains Englis

Re: Multidimensional slicing

2012-10-25 Thread Nathan M. Swan
} } // use result... The worst case here is O(n), where n is the number of links. The slicing of a[i] is O(1). The two associative arrays is probably your best bet, but I'm no expert on this. Hope it helps, Nathan M. Swan

Linking with phobos on compiled dmd, osx 64bit

2012-10-10 Thread Nathan M. Swan
Hello all! I've been hacking on dmd, and something hasn't been working. This is how I compile it: cd dmd/src make -f posix.mak cd ../../druntime make -f posix.mak cd ../phobos make -f posix.mak MODEL=64 cp generated/osx/release/64/libphobos2.a /usr/local/lib/ c

Re: is array an InputRange?

2012-10-05 Thread Nathan M. Swan
On Friday, 5 October 2012 at 13:39:56 UTC, ref2401 wrote: import std.range; int[] numbers = [1, 3, 5, 7, 9, 11]; auto rangeObject = inputRangeObject(numbers); auto inputRange = cast(InputRange!(int[]))rangeObject; why does 'inputRange' equal null? Suggested reading: http://ddili.org/ders/d.

Re: Running unittests in a D library

2012-09-19 Thread Nathan M. Swan
On Wednesday, 19 September 2012 at 18:49:12 UTC, Chris Molozian wrote: Hey all, I'm sure that this is a rather daft question but I've tried to search the d.learn mailing list and must have missed a question about it. I've read the unit testing documentation on dlang.org and I know that `uni

Re: Reading a csv file

2012-08-13 Thread Nathan M. Swan
On Saturday, 11 August 2012 at 14:45:28 UTC, Andrew wrote: On Fri, 10 Aug 2012 03:44:11 +0200, Jesse Phillips wrote: On Friday, 10 August 2012 at 01:39:32 UTC, Andrew wrote: I'm trying to read in a csv file. The examples in the docs for std.csv all assume you're reading from a string rather t

Re: Convert little imperative code to functional coding style

2012-08-10 Thread Nathan M. Swan
On Friday, 10 August 2012 at 18:26:56 UTC, Timon Gehr wrote: Is this what you are looking for? import std.stdio; import std.range: iota; import std.algorithm: map, filter, joiner; import std.typecons : tuple; import std.math : sqrt, floor; void main(){ immutable limi

Re: Chaining a dynamic number of Ranges

2012-07-21 Thread Nathan M. Swan
On Saturday, 21 July 2012 at 16:42:50 UTC, Enerqi wrote: Hello I'm playing around with my first D program and can't figure out a way to chain a dynamic number of ranges. In this example I'm trying to chain a two dimensional array into effectively a one dimensional array, so I can later sort i

Re: Concurrency in D

2012-06-27 Thread Nathan M. Swan
On Wednesday, 27 June 2012 at 22:34:51 UTC, Minas Mina wrote: I have been "playing" latetly with std.concurrency and core.thread. I like both, but they are entirely different approaches to concurrency. Aren't they great? ;) std.concurrency: Uses message passing. Does not allow passing of m

Re: Code-File structure

2012-06-12 Thread Nathan M. Swan
On Tuesday, 12 June 2012 at 07:04:15 UTC, Henrik Valter Vogelius Hansson wrote: Hi! I'm new to D and trying everything out. Got the basics down which are very straightforward and similar to other languages. My professional background is primarily in C/C++-variants and Ruby if it helps. I ha

Re: Array Concatenate

2012-06-08 Thread Nathan M. Swan
On Friday, 8 June 2012 at 12:41:13 UTC, Paul wrote: If this works... D programming book section 4.1.9 Expanding auto a = [87, 40, 10]; a ~= 42; assert(a== [87, 40, 10, 42]); why doesnt' this work? DeletedBlks ~= matchOld[0]; the dmd compiler comes back with Error: cannot append type string to

Re: Simplified socket creation and handling

2012-05-21 Thread Nathan M. Swan
On Monday, 21 May 2012 at 17:54:56 UTC, Adam D. Ruppe wrote: On Saturday, 19 May 2012 at 20:33:49 UTC, Nathan M. Swan wrote: It has some pitfalls (e.g. I can't find a good way to stop the server) When I use it, I just leave it open in a terminal window. Control+C can then kill it. (I

Re: std.concurrency.send

2012-05-20 Thread Nathan M. Swan
On Sunday, 20 May 2012 at 04:09:50 UTC, japplegame wrote: public: void startLogger(LogConstructorArgs args) { loggerTid = spawn(&loggerThread, args); } void log(string msg, OtherOptions oo) { loggerTid.send(LogMsg(msg, oo)); } void stopLogger() { loggerTid.send(QuitMsg()); } private:

Re: std.concurrency.send

2012-05-19 Thread Nathan M. Swan
On Saturday, 19 May 2012 at 21:13:14 UTC, japplegame wrote: You don't need to mark Tids as shared. Okay. I'm writting logger. Logger is global object and it is running in its own separate thread (for example, writting logs to remote database). My application has several threads and all of them

Re: Simplified socket creation and handling

2012-05-19 Thread Nathan M. Swan
On Friday, 18 May 2012 at 06:35:59 UTC, Jarl André wrote: I am a Java developer who is tired of java.nio and similar complex socket libraries. In Java you got QuickServer, the ultimate protocol creation centered socket library. You don't have to write any channels and readers and what not. Yo

Re: std.concurrency.send

2012-05-19 Thread Nathan M. Swan
On Saturday, 19 May 2012 at 13:26:20 UTC, japplegame wrote: Multithreading in D confuses me more and more. import std.concurrency; import std.stdio; shared Tid tid; void main() { send(cast(Tid)tid, "Hello, World"); } void worker() { writeln(receiveOnly!string); } shared static this() { ti

Re: Pointer to variables in D

2012-04-25 Thread Nathan M. Swan
On Thursday, 26 April 2012 at 02:43:35 UTC, Victor Vicente de Carvalho wrote: Hi there, In c++ one can access a pointer to a class/struct variable using this semantic: struct C { int x; }; int C::* ptr = &C::x; C foo; foo.*ptr = 10; assert(foo.x == 10); It is possible to do something lik

Re: [Kinda OT] httpd permissions

2012-04-25 Thread Nathan M. Swan
Have you checked that your web server has write access to /Users/nathanmswan/Sites/ ? Yes, it works now, thanks! NMS P.S. Sorry this might be in the wrong forum, but now I can advertise my homepage as "index.d" instead of compiling it and having it be "index.cgi"

[Kinda OT] httpd permissions

2012-04-25 Thread Nathan M. Swan
How do I deal with this (on OSX); are CGI programs not allowed to write to files? How to change this? Thanks, NMS test.d: #!/usr/local/bin/rdmd import std.stdio; void main() { writeln("Content-type: text/plain\r\n\r\nHello, World!"); } error log: [Wed Apr 25 00:03:01 2012] [error] [cli

Re: comma inside is expression

2012-03-14 Thread Nathan M. Swan
On Thursday, 15 March 2012 at 02:34:45 UTC, Jos van Uden wrote: I've been reading the tutorial on templates and found this example: template rank(T) { static if (is(T t == U[], U)) // is T an array of U, for some type U? enum rank = 1 + rank!(U); // then let’s recurse down. e