template in struct

2013-03-23 Thread dsmith
How to make workable something like this: struct S (T...) { T args; string arg_str; foreach(i; args) { arg_str ~ to!string(i); } } void some_function(S s) { // here ... Error: struct S(T...) is used as a type s.args = [a, b, c]; string args = s.arg_str; }

Re: type determination

2012-11-27 Thread dsmith
On Tuesday, 27 November 2012 at 10:45:19 UTC, Jonathan M Davis wrote: On Tuesday, November 27, 2012 11:30:31 dsmith wrote: Oh, the "static if" ... for compile time evaluation; seems unintuitive (no?) since data is encountered at run time. But the types are known at compile time.

Re: type determination

2012-11-27 Thread dsmith
On Tuesday, 27 November 2012 at 07:28:34 UTC, Jacob Carlborg wrote: On 2012-11-27 06:03, dsmith wrote: How can I make something like the following work without "Error: cannot append type double to type string[]" ? T[] some_function(T[] var) { T[] var2; double a = 12.34; string

type determination

2012-11-26 Thread dsmith
How can I make something like the following work without "Error: cannot append type double to type string[]" ? T[] some_function(T[] var) { T[] var2; double a = 12.34; string b = "hello"; if(typeof(var).stringof == "double") { var2 ~= a; } if(typeof(var).stringof == "string") { var

Re: sort associative array by key

2012-11-23 Thread dsmith
On Friday, 23 November 2012 at 18:24:07 UTC, Timon Gehr wrote: On 11/23/2012 07:09 PM, dsmith wrote: What is the best way to have a function sort an associative array by key? The following yields a conversion error. double[string] aa_sort(double[string] aa) { return aa.keys.sort; } A

sort associative array by key

2012-11-23 Thread dsmith
What is the best way to have a function sort an associative array by key? The following yields a conversion error. double[string] aa_sort(double[string] aa) { return aa.keys.sort; }

modules in other directory trees

2012-10-31 Thread dsmith
What is your way to import modules from other directory trees? Here is my (incorrect?) ideal: Given: /home/user/library_directory/ Containing: lib_one.d lib_two.d lib_interface.d lib_interface.d source: module lib_interface; public import lib_one, lib_two; Implementation in program /home/use

cluster computing

2012-03-03 Thread dsmith
Any suggestions for using std.parallelism (like MPI for C/C++) for server clusters? Alternatively, how might I use MPI with D?

floating point precision

2012-01-11 Thread dsmith
How do you increase floating point precision beyond the default of 6? example: double var = exp(-1.987654321123456789); writeln(var); --> 0.137016 Assuming this result is only an output format issue and that operations are still using double's 64 places, if var above is passed to a function, are

check for running process

2011-10-05 Thread Dsmith
In the core.thread library, there is a method isRunning() which takes a thread. To make code more portable, rather than use a system call or getenv(), how might isRunning() be adapted to check if a program is running? Ideally: isrunning(program_name);

amd64 install dmd2.055

2011-09-24 Thread dsmith
Has anyone here succeeded with a dmd2.055 one-click install to Linux amd64? Unlike the prior dmd2.0xx, I have no luck with dmd2.055 for amd64 installs. I've tried Debian, Fedora, and Suse. After some command line work (based on http://www.d-programming-language.org/dmd- linux.html), it appeare

Re: std.datetime for month integer

2011-07-18 Thread dsmith
Thank you, it works as planned, now as: int mo = Now.month; // --> 7 == Repost the article of Jonathan M Davis (jmdavisp...@gmx.com) == Posted at 2011/07/18 12:14 to digitalmars.D.learn On�Monday�18�July�2011�16:01:06�dsmith�wrote: >�Recall�that�std.date�used�the�following�to�retrieve�a

std.datetime for month integer

2011-07-18 Thread dsmith
Recall that std.date used the following to retrieve a month in integer form (0 .. 11): auto Now = std.date.getUTCtime(); writeln(std.date.monthFromTime(Now)); Using std.datetime, the following yields the abbreviated month name: auto Now = Clock.currTime(); writefln("%s", Now.month);

Re: Fuzzy string matching?

2011-07-15 Thread dsmith
, regex(str)); writeln(m.hit); == Repost the article of Jonathan M Davis (jmdavisp...@gmx.com) == Posted at 2011/07/16 01:08 to digitalmars.D.learn On�Saturday�16�July�2011�05:07:38�dsmith�wrote: >�Until�recently,�you�could�easily�use�std.regexp.search(target_str

Re: Fuzzy string matching?

2011-07-15 Thread dsmith
Until recently, you could easily use std.regexp.search(target_string, find_string), but regexp is apparently no longer in phobos. I seek a simple substitute. std.algorithm.canFind might work, as it is bool. Maybe try something like: foreach(str; strings) foreach(fls; system_files)