Re: Superfluous code in switch statement

2015-09-05 Thread Paul via Digitalmars-d-learn
On Friday, 4 September 2015 at 21:20:11 UTC, Timon Gehr wrote: On 09/04/2015 11:12 PM, anonymous wrote: On Friday 04 September 2015 23:04, Timon Gehr wrote: DMD never warns about dead code. It warns here: import std.stdio; void main() { return; writeln("hi"); /* Warning: stat

Re: spawn X different workers & wait for results from all of them

2015-09-05 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-09-04 17:32:48 +, Justin Whear said: How would receive know? Well, it could be pretty simple. At the moment: receive( int ..., long ..., myStruct ... ) Will wait for one out of the three. So it's an OR. reveive_all( int ..., long ...,

static array is no range?

2015-09-05 Thread Sebastiaan Koppe via Digitalmars-d-learn
``` import std.algorithm; char[1024] buffer; buffer.find("LOCATION: "); // get error about how all the different versions of find don't match ``` ``` import std.algorithm; char[1024] buffer; buffer[0..$].find("LOCATION: "); // works as expected ``` Before trying the slice I manually pragma(msg

Interfacing Chromium & SQLite

2015-09-05 Thread Mike McKee via Digitalmars-d-learn
On a Mac (Yosemite version), how would I create a window in D, embed Chromium, use D to show a local SQLite test database (id, firstname, lastname) inside Chromium, and let someone have a small search form to do like a "full name" search that goes back to D to query the database again?

Re: reading file byLine

2015-09-05 Thread Namal via Digitalmars-d-learn
On Friday, 4 September 2015 at 12:09:19 UTC, Edwin van Leeuwen wrote: On Friday, 4 September 2015 at 12:06:08 UTC, Edwin van Leeuwen wrote: On Friday, 4 September 2015 at 11:50:23 UTC, deed wrote: import std.algorithm, std.range, std.array, std.string, std.stdio, std.conv; int[] arr1 = [1,

Re: Interfacing Chromium & SQLite

2015-09-05 Thread Mike McKee via Digitalmars-d-learn
On Saturday, 5 September 2015 at 11:43:16 UTC, Mike McKee wrote: On a Mac (Yosemite version), how would I create a window in D, embed Chromium, use D to show a local SQLite test database (id, firstname, lastname) inside Chromium, and let someone have a small search form to do like a "full name"

Re: Interfacing Chromium & SQLite

2015-09-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 September 2015 at 13:32:04 UTC, Mike McKee wrote: Note: I'm not asking for source code examples, just wondering what technologies I would have to use to connect these pieces together? I would basically look up how you'd do it in C and follow the same steps in D. I haven't used

Re: reading file byLine

2015-09-05 Thread deed via Digitalmars-d-learn
On Saturday, 5 September 2015 at 12:41:37 UTC, Namal wrote: Thx guys. Now I try out the split function. I read the file as a single string? auto arr = split(cast(string)read(filename),","); where the file has "A", "B", "C" and I get the output ["\"A\"", " \"B\"", " \"C\"\n"] I can understand

Re: reading file byLine

2015-09-05 Thread deed via Digitalmars-d-learn
On Saturday, 5 September 2015 at 14:44:19 UTC, deed wrote: .map!(s => chomp(s, "\"") .map!(s => chompPrefix(s, "\"") should be .map!(s => chomp(s, "\"")) .map!(s => chompPrefix(s, "\""))

Re: spawn X different workers & wait for results from all of them

2015-09-05 Thread thedeemon via Digitalmars-d-learn
On Thursday, 3 September 2015 at 16:50:21 UTC, Robert M. Münch wrote: Hi, I'm not sure how to best implement the following: 1. I have 4 different tasks to do. 2. All can run in parallel 3. Every task will return some result that I need Now how to best do it? I think the Task and taskPool from

Re: spawn X different workers & wait for results from all of them

2015-09-05 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-09-05 15:44:02 +, thedeemon said: I think the Task and taskPool from std.parallelism are a good fit. Something like: auto task1 = task!fun1(params1); auto task2 = task!fun2(params2); auto task3 = task!fun3(params3); auto task4 = task!fun4(params4); taskPool.put(task1); taskPool.put

Re: reading file byLine

2015-09-05 Thread Namal via Digitalmars-d-learn
On Saturday, 5 September 2015 at 14:49:13 UTC, deed wrote: On Saturday, 5 September 2015 at 14:44:19 UTC, deed wrote: .map!(s => chomp(s, "\"") .map!(s => chompPrefix(s, "\"") should be .map!(s => chomp(s, "\"")) .map!(s => chompPrefix(s, "\"")) Yeah, I have have been trying this exampl

Create a delegate function

2015-09-05 Thread Prudence via Digitalmars-d-learn
I have code setup in such a way that I call a user defined function, e.g., void myFunc(Data d) { } myFunc has to be passed to the main code using something like void SetFunc(void function(Data) func) { ... func(myData); } What I would like to do is, instead of having to pass data to myF

Re: reading file byLine

2015-09-05 Thread deed via Digitalmars-d-learn
On Saturday, 5 September 2015 at 17:31:39 UTC, Namal wrote: Yeah, I have have been trying this example from wiki books https://en.wikibooks.org/wiki/Learning_D_With_Project_Euler It is not even compiling. What exactly is not compiling?

Windows Resources

2015-09-05 Thread Prudence via Digitalmars-d-learn
I'm trying to create a win32 window. I coped the code pretty much directly from msdn: MSG msg; BOOL bRet; WNDCLASS wc; // Register the window class for the main window. if (!hPrevInstance) {

Re: Create a delegate function

2015-09-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 September 2015 at 18:00:53 UTC, Prudence wrote: I have code setup in such a way that I call a user defined function, e.g., void myFunc(Data d) { } myFunc has to be passed to the main code using something like You can do that if and only if the this is the last argument t

Re: Create a delegate function

2015-09-05 Thread BBasile via Digitalmars-d-learn
On Saturday, 5 September 2015 at 18:00:53 UTC, Prudence wrote: I have code setup in such a way that I call a user defined function, e.g., void myFunc(Data d) { } myFunc has to be passed to the main code using something like void SetFunc(void function(Data) func) { ... func(myData); } Wh

Re: Windows Resources

2015-09-05 Thread BBasile via Digitalmars-d-learn
On Saturday, 5 September 2015 at 19:06:15 UTC, Prudence wrote: [...] Check this file https://github.com/D-Programming-Language/dmd/blob/master/samples/winsamp.d ,it's distributed with your D setup.

Re: reading file byLine

2015-09-05 Thread Namal via Digitalmars-d-learn
On Saturday, 5 September 2015 at 18:57:52 UTC, deed wrote: On Saturday, 5 September 2015 at 17:31:39 UTC, Namal wrote: Yeah, I have have been trying this example from wiki books https://en.wikibooks.org/wiki/Learning_D_With_Project_Euler It is not even compiling. What exactly is not compilin

Re: reading file byLine

2015-09-05 Thread anonymous via Digitalmars-d-learn
On Saturday 05 September 2015 22:22, Namal wrote: > import std.stdio, std.algorithm, std.array; > > bool abundant(int n){ [...] > } > > > > void main(){ > > long sum; > int[] arr; > int[28123] mark; > > foreach(i;1..28124) > if(abundant(i)) >

Re: Windows Resources

2015-09-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 September 2015 at 19:06:15 UTC, Prudence wrote: That's about as far as I can get. (what resource data? Where I do put it? How, who, when?) Resource data in Windows is data compiled into your exe. It is stuff like icons, menus, or other arbitrary stuff you attach. However, the

Re: static array is no range?

2015-09-05 Thread cym13 via Digitalmars-d-learn
On Saturday, 5 September 2015 at 11:12:17 UTC, Sebastiaan Koppe wrote: ``` import std.algorithm; char[1024] buffer; buffer.find("LOCATION: "); // get error about how all the different versions of find don't match ``` ``` import std.algorithm; char[1024] buffer; buffer[0..$].find("LOCATION: ");

Re: static array is no range?

2015-09-05 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Sunday, 6 September 2015 at 00:25:10 UTC, cym13 wrote: Yes, static arrays aren't ranges. The main reason is that static arrays are value type (ie: you copy them arround when passing them to functions which usually has a huge cost) where ranges are reference type (no copy, lighter, not always

Re: Windows Resources

2015-09-05 Thread Prudence via Digitalmars-d-learn
On Sunday, 6 September 2015 at 00:29:13 UTC, Adam D. Ruppe wrote: On Saturday, 5 September 2015 at 19:06:15 UTC, Prudence wrote: That's about as far as I can get. (what resource data? Where I do put it? How, who, when?) Resource data in Windows is data compiled into your exe. It is stuff like

Re: Windows Resources

2015-09-05 Thread Rikki Cattermole via Digitalmars-d-learn
This may interest you: https://github.com/Devisualization/window/blob/master/platforms/win32/devisualization/window/window.d