Re: reading file byLine

2015-09-06 Thread Namal via Digitalmars-d-learn
On Sunday, 6 September 2015 at 20:39:27 UTC, deed wrote: On Sunday, 6 September 2015 at 17:57:49 UTC, Namal wrote: Yeah, I just checked, it is 2.066, how can I install the new version on ubuntu with sudo apt-get? sudo apt-get install dmd will give you dmd v2.067.1. Don't know when it will

Re: Are there any Phobos functions to check file permissions on Windows and Posix?

2015-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 06, 2015 20:40:03 Gary Willoughby via Digitalmars-d-learn wrote: > Are there any Phobos functions to check file permissions on > Windows and Posix? For example, I want to check if a file is > readable and/or writable in a cross-platform fashion. Does anyone > have an example?

Re: Regression?

2015-09-06 Thread Sebastiaan Koppe via Digitalmars-d-learn
Dammit, i am on windows, DMD32 D Compiler v2.068.0

Re: How To: Passing curried functions around

2015-09-06 Thread Meta via Digitalmars-d-learn
The name validator_t is not idiomatic in D. Something like ValidatorFun should be preferred. Same for intReader_t; ReadIntFun is probably preferred, or even IntReader (but that would imply that it's a struct/class in my mind). As for the actual use of partial, it's perfectly fine and

Re: reading file byLine

2015-09-06 Thread Namal via Digitalmars-d-learn
That should be it though... Could you try this minimal complete test? import std.stdio; import std.algorithm; void main(string[] args) { int[] arr = [1, 2, 4, 2, 3, 4, 1]; arr.sort.uniq.writeln; } // [1, 2, 3, 4] yes, it works likte that. unique(arr) I get Error: undefined

Re: reading file byLine

2015-09-06 Thread Namal via Digitalmars-d-learn
Well, if you don't type function names right, it will be hard to help you. oh, sorry. But I found out what I have been doing wrong besides that. arr.sort.uniq; uniq(arr) or arr.sort.uniq; compiles but doesn't store it in the arr array, I need to store it in a new one.

Are there any Phobos functions to check file permissions on Windows and Posix?

2015-09-06 Thread Gary Willoughby via Digitalmars-d-learn
Are there any Phobos functions to check file permissions on Windows and Posix? For example, I want to check if a file is readable and/or writable in a cross-platform fashion. Does anyone have an example?

Re: What's the "right" way to do openmp-style parallelism?

2015-09-06 Thread Meta via Digitalmars-d-learn
On Monday, 7 September 2015 at 02:56:04 UTC, Charles wrote: Friends, I have a program that would be pretty easy to parallelize with an openmp pragra in C. I'd like to avoid the performance cost of using message passing, and the shared qualifier seems like it's enforcing guarantees I don't

Re: How To: Passing curried functions around

2015-09-06 Thread welkam via Digitalmars-d-learn
Now its clearer to me. You want delegates http://wiki.dlang.org/Function_literals

Re: reading file byLine

2015-09-06 Thread cym13 via Digitalmars-d-learn
On Sunday, 6 September 2015 at 21:01:09 UTC, Namal wrote: On Sunday, 6 September 2015 at 20:39:27 UTC, deed wrote: On Sunday, 6 September 2015 at 17:57:49 UTC, Namal wrote: Yeah, I just checked, it is 2.066, how can I install the new version on ubuntu with sudo apt-get? sudo apt-get

Re: reading file byLine

2015-09-06 Thread cym13 via Digitalmars-d-learn
On Sunday, 6 September 2015 at 21:18:28 UTC, Namal wrote: That should be it though... Could you try this minimal complete test? import std.stdio; import std.algorithm; void main(string[] args) { int[] arr = [1, 2, 4, 2, 3, 4, 1]; arr.sort.uniq.writeln; } // [1, 2, 3, 4] yes, it

Re: reading file byLine

2015-09-06 Thread deed via Digitalmars-d-learn
On Sunday, 6 September 2015 at 17:57:49 UTC, Namal wrote: Yeah, I just checked, it is 2.066, how can I install the new version on ubuntu with sudo apt-get? sudo apt-get install dmd will give you dmd v2.067.1. Don't know when it will be upgraded to 2.068 though.

What's the "right" way to do openmp-style parallelism?

2015-09-06 Thread Charles via Digitalmars-d-learn
Friends, I have a program that would be pretty easy to parallelize with an openmp pragra in C. I'd like to avoid the performance cost of using message passing, and the shared qualifier seems like it's enforcing guarantees I don't need. Essentially, I have x = float[imax][jmax]; //x is about

Regression?

2015-09-06 Thread Sebastiaan Koppe via Digitalmars-d-learn
This used to work in older compiler (might have been v2.067 or v2.066, not older). ``` #!rdmd import std.stdio; import std.json; import std.algorithm; void main() { auto ls = File("../languages.json","r").byLineCopy().joiner.parseJSON(); } ``` Error:

Re: How to partially forward properties of struct array member to struct (disable length property) ?

2015-09-06 Thread bioinfornatics via Digitalmars-d-learn
On Sunday, 6 September 2015 at 07:34:36 UTC, ParticlePeter wrote: I am working on a struct vector. The data is stored in a member static array and I want to be able to forward all array properties except length to vector. Reason is I have free functions f that take vector(s) as arguments, such

How to partially forward properties of struct array member to struct (disable length property) ?

2015-09-06 Thread ParticlePeter via Digitalmars-d-learn
I am working on a struct vector. The data is stored in a member static array and I want to be able to forward all array properties except length to vector. Reason is I have free functions f that take vector(s) as arguments, such that f(vector) and vector.f via UFCS is possible. Using alias

Re: Interfacing Chromium & SQLite

2015-09-06 Thread Byron Heads via Digitalmars-d-learn
On Saturday, 5 September 2015 at 13:32:04 UTC, Mike McKee wrote: 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,

Re: Is D suitable for my latest project?

2015-09-06 Thread BBasile via Digitalmars-d-learn
On Sunday, 6 September 2015 at 14:36:53 UTC, chris stevens wrote: - dynamic creation of classes/structs at runtime. You have Object.factory for this. You can also use a custom factory based on string comparison. (with some: static if(condition) return new This; else static if(otherCondition)

Is D suitable for my latest project?

2015-09-06 Thread chris stevens via Digitalmars-d-learn
Hi All, I am considering using D for my latest project and there are a few features I would like and am not entirely sure at this point whether D has them. They are: - dynamic creation of classes/structs at runtime (think I can emulate this with variants/dynamic) - dynamic compilation of

Re: Is D suitable for my latest project?

2015-09-06 Thread chris stevens via Digitalmars-d-learn
On Sunday, 6 September 2015 at 14:36:53 UTC, chris stevens wrote: - dynamic compilation of code files at runtime I guess I could just invoke the compiler from my code for this? I would also like to be able to load this compiled code into the current process. This probably can be achieved

Re: Windows Resources

2015-09-06 Thread Kagamin via Digitalmars-d-learn
On Sunday, 6 September 2015 at 02:37:21 UTC, Prudence wrote: Obviously the issue is that I'm not using any resources yet it is giving me such an error. You do. See docs for lpszMenuName field. GUI projects generated by Visual Studio include resource generation, that's why it works for them.

Re: Windows Resources

2015-09-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 6 September 2015 at 10:28:59 UTC, Kagamin wrote: You do. See docs for lpszMenuName field. I can't believe I missed that!

Re: How to partially forward properties of struct array member to struct (disable length property) ?

2015-09-06 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 6 September 2015 at 08:48:32 UTC, bioinfornatics wrote: On Sunday, 6 September 2015 at 07:34:36 UTC, ParticlePeter wrote: I am working on a struct vector. The data is stored in a member static array and I want to be able to forward all array properties except length to vector.

Re: How to partially forward properties of struct array member to struct (disable length property) ?

2015-09-06 Thread via Digitalmars-d-learn
Untested: struct Vector(T) { T[42] data; auto opDispatch(string func, Args...)(Args args) if(is(typeof(mixin("data."~func)(Args.init))) && func != "length") { return mixin("data."~func)(Args.init); } }

Re: reading file byLine

2015-09-06 Thread Namal via Digitalmars-d-learn
Are you on 2.066 or older? Back then std.algorithm hasn't been split into submodules yet. Just import std.algorithm then instead of std.algorithm.comparison, std.algorithm.iteration, etc. Yeah, I just checked, it is 2.066, how can I install the new version on ubuntu with sudo apt-get? I

Re: Interface "indexing"

2015-09-06 Thread Kagamin via Digitalmars-d-learn
On Sunday, 6 September 2015 at 17:32:11 UTC, Prudence wrote: And to fire the event, instead of a huge switch(or essentially the same), one can write one line of code or so and have D take care of matching up things. (essentially for some enum value I want a corresponding type to be associated

Re: Interface "indexing"

2015-09-06 Thread Kagamin via Digitalmars-d-learn
Well, you can have an array of event factories: IEvent function()[2] factories = [ factory1, factory2 ]; IEvent factory1() { return new Event1(); } IEvent factory2() { return new Event2(); } Then use enum for indexing: IEvent e = factories[NumEvent1]();

Re: Interface "indexing"

2015-09-06 Thread Prudence via Digitalmars-d-learn
On Sunday, 6 September 2015 at 18:11:44 UTC, Kagamin wrote: Well, you can have an array of event factories: IEvent function()[2] factories = [ factory1, factory2 ]; IEvent factory1() { return new Event1(); } IEvent factory2() { return new Event2(); } Then use enum for indexing: IEvent e =

Re: Windows Resources

2015-09-06 Thread Kagamin via Digitalmars-d-learn
On Sunday, 6 September 2015 at 15:42:52 UTC, Prudence wrote: So how does one actually include resources such as menu's (rc files and all that) in a D project? Or am I stuff creating all that stuff programmatically? Just like in a C project: write, compile and link them.

Re: reading file byLine

2015-09-06 Thread anonymous via Digitalmars-d-learn
On Sunday, 6 September 2015 at 15:41:34 UTC, Namal wrote: is there any function that removes double elements in a sorted array? std.algorithm.iteration.uniq http://dlang.org/phobos/std_algorithm_iteration.html#uniq

Re: Is D suitable for my latest project?

2015-09-06 Thread chris stevens via Digitalmars-d-learn
Thanks so much for your reply. On Sunday, 6 September 2015 at 14:45:45 UTC, BBasile wrote: if you mean to generate code as string, writing them to a file, of course it will work in D. I guess you're right it wouldn't be too difficult to do it all using strings. The code generation I'd done

Re: reading file byLine

2015-09-06 Thread Namal via Digitalmars-d-learn
Note that there's a specialized `std.algorithm.iteration.sum`. is there any function that removes double elements in a sorted array?

Re: Windows Resources

2015-09-06 Thread Prudence via Digitalmars-d-learn
On Sunday, 6 September 2015 at 10:28:59 UTC, Kagamin wrote: On Sunday, 6 September 2015 at 02:37:21 UTC, Prudence wrote: Obviously the issue is that I'm not using any resources yet it is giving me such an error. You do. See docs for lpszMenuName field. GUI projects generated by Visual Studio

Re: reading file byLine

2015-09-06 Thread Namal via Digitalmars-d-learn
On Sunday, 6 September 2015 at 15:52:38 UTC, anonymous wrote: On Sunday, 6 September 2015 at 15:41:34 UTC, Namal wrote: is there any function that removes double elements in a sorted array? std.algorithm.iteration.uniq http://dlang.org/phobos/std_algorithm_iteration.html#uniq Hmm, I get

Re: reading file byLine

2015-09-06 Thread anonymous via Digitalmars-d-learn
On Sunday, 6 September 2015 at 16:17:29 UTC, Namal wrote: Error: module comparison is in file 'std/algorithm/comparison.d' which cannot be read import path[0] = /usr/include/dmd/phobos import path[1] = /usr/include/dmd/druntime/import when I try to load the headers like in the example Are

How To: Passing curried functions around

2015-09-06 Thread Bahman Movaqar via Digitalmars-d-learn
I'm just learning D, so please bear with me if I'm asking something naive. Consider the following code skeleton: // in part A of the application... // - alias bool function(int n) validator_t; bool isEven(int n) {

Re: How To: Passing curried functions around

2015-09-06 Thread Bahman Movaqar via Digitalmars-d-learn
On Sunday, 6 September 2015 at 19:22:41 UTC, welkam wrote: I dont know much about functional programming, but what stops you defining int readInt(string prompt, validator_t validator) { ... } as a free standing function and just call it from both parts of your code? What is the benefit of