Re: Check if give an array is equal to first elements in another array

2014-10-16 Thread Ali Çehreli via Digitalmars-d-learn
On 10/15/2014 09:35 PM, MachineCode wrote: Is there one function in the Phobos library to check if give an array is equal to first elements in another array? e.g, f(a, b) the entire b array must match to first elements in a and then return true otherwise false, ie: a[0 .. b.length] == b

Re: extern (C) function call with const char * type will sometimes generate seg fault or core dump.

2014-10-16 Thread Ali Çehreli via Digitalmars-d-learn
On 10/15/2014 08:18 PM, dysmondad wrote: Since I've added this call, my program will sometimes but not always either generate a core dump or a seg fault. It seems that the issue is with the const char * parameter. I don't have a good grasp of the difference between the way D and C work for

Re: extern (C) function call with const char * type will sometimes generate seg fault or core dump.

2014-10-16 Thread Mike Parker via Digitalmars-d-learn
On 10/16/2014 12:18 PM, dysmondad wrote: Since I've added this call, my program will sometimes but not always either generate a core dump or a seg fault. It seems that the issue is with the const char * parameter. I don't have a good grasp of the difference between the way D and C work for char

Re: extern (C) function call with const char * type will sometimes generate seg fault or core dump.

2014-10-16 Thread Mike Parker via Digitalmars-d-learn
On 10/16/2014 4:54 PM, Mike Parker wrote: On 10/16/2014 12:18 PM, dysmondad wrote: Since I've added this call, my program will sometimes but not always either generate a core dump or a seg fault. It seems that the issue is with the const char * parameter. I don't have a good grasp of the

Using return type of a predicate function as a template

2014-10-16 Thread Edwin van Leeuwen via Digitalmars-d-learn
I am trying to implement a groupBy function that groups by the return type of a predicate. Currently I have to define the returntype of the predicate for it to compile. Is there a way to get the return type at compile time and use it. The code: V[K] groupBy( alias func, K, V )( V values ) {

Re: Very strange compilation error

2014-10-16 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 15 October 2014 at 21:28:05 UTC, Nils Boßung wrote: On Wednesday 15 October 2014 22:13, John Colvin wrote: On Wednesday, 15 October 2014 at 19:29:27 UTC, Jack Applegame wrote: I don't understand why this code doesn't compile: http://dpaste.dzfl.pl/dfd8df7f80ad that should be

Re: Using return type of a predicate function as a template

2014-10-16 Thread Atila Neves via Digitalmars-d-learn
This works: import std.range; auto groupBy(alias func, R)(R values) if (isInputRange!R) { alias K = typeof(func(values.front)); alias V = ElementType!R[]; V[K] grouped; foreach(value; values) grouped[func(value)] ~= value; return grouped; } unittest { struct Test {

Re: Using return type of a predicate function as a template

2014-10-16 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Thursday, 16 October 2014 at 08:18:02 UTC, Atila Neves wrote: This works: import std.range; auto groupBy(alias func, R)(R values) if (isInputRange!R) { alias K = typeof(func(values.front)); alias V = ElementType!R[]; V[K] grouped; foreach(value; values)

Re: Simple import question

2014-10-16 Thread Rei Roldan via Digitalmars-d-learn
On Wednesday, 15 October 2014 at 16:11:22 UTC, Steven Schveighoffer wrote: *snip* You might of missed Adam's response up there: But the best way is to explicitly pass all the file names to the compiler: dmd yourfile.d file2.d folder/file3.d and so on... Doing that will serve you best in

Re: Simple import question

2014-10-16 Thread Sag Academy via Digitalmars-d-learn
On Thursday, 16 October 2014 at 10:59:29 UTC, Rei Roldan wrote: On Wednesday, 15 October 2014 at 16:11:22 UTC, Steven Schveighoffer wrote: *snip* You might of missed Adam's response up there: But the best way is to explicitly pass all the file names to the compiler: dmd yourfile.d

Re: Simple import question

2014-10-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/16/14 6:59 AM, Rei Roldan wrote: On Wednesday, 15 October 2014 at 16:11:22 UTC, Steven Schveighoffer wrote: *snip* You might of missed Adam's response up there: But the best way is to explicitly pass all the file names to the compiler: dmd yourfile.d file2.d folder/file3.d and so

Re: Really in need of help with std.container.array.d

2014-10-16 Thread Robert burner Schadek via Digitalmars-d-learn
On Wednesday, 15 October 2014 at 21:15:14 UTC, Nordlöw wrote: Comint exited abnormally with code 1 at Wed Oct 15 23:14:37 I'm stuck. Need help. I will give it a try

Re: Really in need of help with std.container.array.d

2014-10-16 Thread Nordlöw
On Thursday, 16 October 2014 at 13:56:18 UTC, Robert burner Schadek wrote: I'm stuck. Need help. I will give it a try Thank you.

Using __traits to find functions in sub-modules

2014-10-16 Thread nrgyzer via Digitalmars-d-learn
Hi, I'm using structs to describe my functions: struct example { string name; uint someValue; } module mod.example1; @example(example1, 1) void myFunction() { // do something } module mod.example2; @example(example2, 2) void myFunction() { // do something } I'm using the struct to

How to check i

2014-10-16 Thread Uranuz via Digitalmars-d-learn
I have some string *str* of unicode characters. The question is how to check if I have valid unicode code point starting at code unit *index*? I need it because I try to write parser that operates on string by *code unit*. If more precisely I trying to write function *matchWord* that should

Re: Using __traits to find functions in sub-modules

2014-10-16 Thread ketmar via Digitalmars-d-learn
On Thu, 16 Oct 2014 18:39:48 + nrgyzer via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: But it always stats that 'cmodule' has no members. Does anyone know how to solve the problem? there is no non-hackish solution, afaik. there is no even hackish, but reliable one.

Re: Using __traits to find functions in sub-modules

2014-10-16 Thread John Colvin via Digitalmars-d-learn
On Thursday, 16 October 2014 at 18:39:50 UTC, nrgyzer wrote: Hi, I'm using structs to describe my functions: struct example { string name; uint someValue; } module mod.example1; @example(example1, 1) void myFunction() { // do something } module mod.example2; @example(example2, 2) void

Re: how to get the \uxxxx unicode code from a char

2014-10-16 Thread Sean Kelly via Digitalmars-d-learn
On Tuesday, 14 October 2014 at 20:08:03 UTC, Brad Anderson wrote: On Tuesday, 14 October 2014 at 20:05:07 UTC, Brad Anderson wrote: https://github.com/D-Programming-Language/phobos/blob/master/std/json.d#L579 Oops. Linked the the parser section. I actually don't see any unicode escape

Re: How to check i

2014-10-16 Thread spir via Digitalmars-d-learn
On 16/10/14 20:46, Uranuz via Digitalmars-d-learn wrote: I have some string *str* of unicode characters. The question is how to check if I have valid unicode code point starting at code unit *index*? [...] You cannot do that without decoding. Cheking whether utf-x is valid and decoding are

Re: How to check i

2014-10-16 Thread Ali Çehreli via Digitalmars-d-learn
On 10/16/2014 12:43 PM, spir via Digitalmars-d-learn wrote: denis spir is back! :) On 10/16/2014 11:46 AM, Uranuz wrote: I have some string *str* of unicode characters. The question is how to check if I have valid unicode code point starting at code unit *index*? It is easy if I

Any dub tips and tricks

2014-10-16 Thread Joel via Digitalmars-d-learn
Any way of using dub (on Windows or OSX). I've been trying it lately, but not much success. 1. (In the command prompt or Terminal), I create a new folder. 2. Run 'dub init' in the new folder 3. I copy the dependency from a lib/app into the dub.json file. 4. Then I just enter 'dub' In Windows I

Beginner ?. Why does D suggest to learn java

2014-10-16 Thread RBfromME via Digitalmars-d-learn
I'm a newbie to programming and have been looking into the D lang as a general purposing language to learn, yet the D overview indicates that java would be a better language to learn for your first programming language. Why? Looks like D is easier than Java...

Re: Beginner ?. Why does D suggest to learn java

2014-10-16 Thread Ali Çehreli via Digitalmars-d-learn
On 10/16/2014 03:26 PM, RBfromME wrote: I'm a newbie to programming and have been looking into the D lang as a general purposing language to learn, yet the D overview indicates that java would be a better language to learn for your first programming language. Why? Looks like D is easier

Re: Beginner ?. Why does D suggest to learn java

2014-10-16 Thread Brad Anderson via Digitalmars-d-learn
On Thursday, 16 October 2014 at 22:26:51 UTC, RBfromME wrote: I'm a newbie to programming and have been looking into the D lang as a general purposing language to learn, yet the D overview indicates that java would be a better language to learn for your first programming language. Why? Looks

Re: Is this a bug when creating proxies in classes?

2014-10-16 Thread Martin Nowak via Digitalmars-d-learn
On Monday, 25 August 2014 at 18:10:33 UTC, Gary Willoughby wrote: class Foo { private int foo; mixin Proxy!(foo); this(int x) { this.foo = x; } } Apparently Proxy

Re: Beginner ?. Why does D suggest to learn java

2014-10-16 Thread ketmar via Digitalmars-d-learn
On Thu, 16 Oct 2014 22:43:11 + Brad Anderson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: also shows just how old the Overview is (where do you even get a BASIC compiler these days?). voila: http://www.freebasic.net/ ;-) signature.asc Description: PGP signature

Re: Beginner ?. Why does D suggest to learn java

2014-10-16 Thread MachineCode via Digitalmars-d-learn
On Thursday, 16 October 2014 at 22:42:21 UTC, Ali Çehreli wrote: On 10/16/2014 03:26 PM, RBfromME wrote: I'm a newbie to programming and have been looking into the D lang as a general purposing language to learn, yet the D overview indicates that java would be a better language to learn for

Re: Beginner ?. Why does D suggest to learn java

2014-10-16 Thread ketmar via Digitalmars-d-learn
On Fri, 17 Oct 2014 00:52:14 + MachineCode via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I don't understand. If at least it were C but java? why not D itself? C is *awful* as beginner's language. never ever let people start with C if you don't hate 'em. as for D...

Re: Beginner ?. Why does D suggest to learn java

2014-10-16 Thread bearophile via Digitalmars-d-learn
RBfromME: I'm a newbie to programming and have been looking into the D lang as a general purposing language to learn, yet the D overview indicates that java would be a better language to learn for your first programming language. Why? Looks like D is easier than Java... Python is probably

Re: extern (C) function call with const char * type will sometimes generate seg fault or core dump.

2014-10-16 Thread dysmondad via Digitalmars-d-learn
On Thursday, 16 October 2014 at 07:55:24 UTC, Mike Parker wrote: On 10/16/2014 4:54 PM, Mike Parker wrote: On 10/16/2014 12:18 PM, dysmondad wrote: Since I've added this call, my program will sometimes but not always either generate a core dump or a seg fault. It seems that the issue is with

Re: Beginner ?. Why does D suggest to learn java

2014-10-16 Thread via Digitalmars-d-learn
On Friday, 17 October 2014 at 01:14:34 UTC, bearophile wrote: Python is probably a better first language than Java. D is a little too much complex as first language. The IDE support is probably a bit better with Java/C# and using a statically typed language as your first language has

Re: Beginner ?. Why does D suggest to learn java

2014-10-16 Thread maarten van damme via Digitalmars-d-learn
While d can be complex, there's nothing preventing you from starting out simple and not using all features at first. I don't understand why it's not suitable for a beginner if you use this approach... 2014-10-17 6:51 GMT+02:00 via Digitalmars-d-learn digitalmars-d-learn@puremagic.com: On