Re: For those ready to take the challenge

2015-01-09 Thread Vladimir Panteleev via Digitalmars-d-learn
On Saturday, 10 January 2015 at 02:10:04 UTC, Jesse Phillips wrote: On Friday, 9 January 2015 at 13:50:29 UTC, eles wrote: https://codegolf.stackexchange.com/questions/44278/debunking-stroustrups-debunking-of-the-myth-c-is-for-large-complicated-pro Link to answer in D:

Wrapping a C library with its own GC + classes vs refcounted structs

2015-01-09 Thread aldanor via Digitalmars-d-learn
Hi all, I was wondering what's the most D-idiomatic way of dealing with a C library (or rather writing wrappers for a C library) that does its own GC via reference counting. The objects are identified and passed around by integer ids only; most functions like find me an object foo in object

Re: For those ready to take the challenge

2015-01-09 Thread Jesse Phillips via Digitalmars-d-learn
On Friday, 9 January 2015 at 13:50:29 UTC, eles wrote: https://codegolf.stackexchange.com/questions/44278/debunking-stroustrups-debunking-of-the-myth-c-is-for-large-complicated-pro Link to answer in D: http://codegolf.stackexchange.com/a/44417/13362

Re: For those ready to take the challenge

2015-01-09 Thread Andrei Alexandrescu via Digitalmars-d-learn
On 1/9/15 6:10 PM, Jesse Phillips wrote: On Friday, 9 January 2015 at 13:50:29 UTC, eles wrote: https://codegolf.stackexchange.com/questions/44278/debunking-stroustrups-debunking-of-the-myth-c-is-for-large-complicated-pro Link to answer in D: http://codegolf.stackexchange.com/a/44417/13362

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread ketmar via Digitalmars-d-learn
On Fri, 09 Jan 2015 15:36:21 + FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 9 January 2015 at 14:03:21 UTC, ketmar via Digitalmars-d-learn wrote: On Fri, 09 Jan 2015 13:54:00 + Robert burner Schadek via Digitalmars-d-learn

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread FrankLike via Digitalmars-d-learn
On Friday, 9 January 2015 at 15:57:21 UTC, ketmar via Digitalmars-d-learn wrote: On Fri, 09 Jan 2015 15:36:21 + FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 9 January 2015 at 14:03:21 UTC, ketmar via Digitalmars-d-learn wrote: On Fri, 09 Jan

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread FrankLike via Digitalmars-d-learn
On Friday, 9 January 2015 at 14:03:21 UTC, ketmar via Digitalmars-d-learn wrote: On Fri, 09 Jan 2015 13:54:00 + Robert burner Schadek via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 9 January 2015 at 13:25:17 UTC, ketmar via Digitalmars-d-learn wrote: if you

Re: Parameterized enum does not work

2015-01-09 Thread Daniel Kozak via Digitalmars-d-learn
On Friday, 9 January 2015 at 07:52:50 UTC, Daniel Kozak wrote: On Friday, 9 January 2015 at 07:50:53 UTC, Daniel Kozak wrote: On Friday, 9 January 2015 at 06:17:53 UTC, Andre wrote: Hi, Should following coding work? string lpad(ubyte length, long n) { import std.string: rightJustify;

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread FrankLike via Digitalmars-d-learn
iday, 9 January 2015 at 07:41:07 UTC, ketmar via Digitalmars-d-learn wrote: On Fri, 09 Jan 2015 07:10:14 + FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 8 January 2015 at 15:15:59 UTC, Robert burner Schadek wrote: use canFind like such:

Re: Fastest Way of Accessing Entries in an AA

2015-01-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 09, 2015 07:51:27 Foo via Digitalmars-d-learn wrote: On Friday, 9 January 2015 at 06:18:53 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: On Friday, January 09, 2015 00:20:07 Foo via Digitalmars-d-learn wrote: You know, that you kan reuse the result of the in

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread ketmar via Digitalmars-d-learn
On Fri, 09 Jan 2015 09:36:01 + FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Sorry,it's only a example .Thank you work hard,but it's not what I want. 'indexOfAny ' function should do this work. ”he is at home ,[home,office,”sea,plane], in

Re: Parameterized enum does not work

2015-01-09 Thread Andre via Digitalmars-d-learn
Thanks a lot. Kind regards André On Friday, 9 January 2015 at 07:59:51 UTC, Daniel Kozak wrote: On Friday, 9 January 2015 at 07:52:50 UTC, Daniel Kozak wrote: On Friday, 9 January 2015 at 07:50:53 UTC, Daniel Kozak wrote: On Friday, 9 January 2015 at 06:17:53 UTC, Andre wrote: Hi, Should

Tuples not working?

2015-01-09 Thread Jonathan Marler via Digitalmars-d-learn
import std.stdio; import std.typecons; void main() { alias TL = Tuple!(int, long, float); foreach (i, T; TL) writefln(TL[%d] = %s, i, typeid(T)); } Why is this not working? D:\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(419): Error: need 'this' for '_expand_field_0' of type 'int'

Re: For those ready to take the challenge

2015-01-09 Thread Adam D. Ruppe via Digitalmars-d-learn
Huh, looking at the answers on the website, they're mostly using regular expressions. Weaksauce. And wrong - they don't find ALL the links, they find the absolute HTTP urls!

Re: For those ready to take the challenge

2015-01-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 9 January 2015 at 16:55:30 UTC, Justin Whear wrote: Was excited to give it a try, then remembered...std.xml :( Well, as the author of my dom.d, I think it counts as a first party library when I use it! --- import arsd.dom; import std.net.curl; import std.stdio, std.algorithm;

Re: dco how to specify Jpath?

2015-01-09 Thread FrankLike via Digitalmars-d-learn
On Sunday, 21 December 2014 at 07:43:14 UTC, FrankLike wrote: On Thursday, 20 November 2014 at 10:48:17 UTC, Suliman wrote: I am playing with dco. And it's look very helpful for tiny projects. I can't understand is it's possible to add to dco.ini Jpath? I am talking about something like:

Re: For those ready to take the challenge

2015-01-09 Thread Justin Whear via Digitalmars-d-learn
On Fri, 09 Jan 2015 13:50:28 +, eles wrote: https://codegolf.stackexchange.com/questions/44278/debunking- stroustrups-debunking-of-the-myth-c-is-for-large-complicated-pro Was excited to give it a try, then remembered...std.xml :(

Re: For those ready to take the challenge

2015-01-09 Thread Justin Whear via Digitalmars-d-learn
On Fri, 09 Jan 2015 17:18:42 +, Adam D. Ruppe wrote: Huh, looking at the answers on the website, they're mostly using regular expressions. Weaksauce. And wrong - they don't find ALL the links, they find the absolute HTTP urls! Yes, I noticed that. `script src=http://app.js`/script` isn't

Cast a struct to void*

2015-01-09 Thread John Colvin via Digitalmars-d-learn
struct S { void* p; } void main() { S s; auto a = cast(void*)s; //Error: e2ir: cannot cast s of type S to type void* } Is there are a good reason for this being disallowed?

Re: Cast a struct to void*

2015-01-09 Thread anonymous via Digitalmars-d-learn
On Friday, 9 January 2015 at 18:25:42 UTC, John Colvin wrote: struct S { void* p; } void main() { S s; auto a = cast(void*)s; //Error: e2ir: cannot cast s of type S to type void* } Is there are a good reason for this being disallowed? You'd expect `cast(void*)s == s.p`? That

Re: Cast a struct to void*

2015-01-09 Thread Ali Çehreli via Digitalmars-d-learn
On 01/09/2015 10:25 AM, John Colvin wrote: struct S { void* p; } void main() { S s; auto a = cast(void*)s; //Error: e2ir: cannot cast s of type S to type void* } Is there are a good reason for this being disallowed? I know two options: a) alias p this; b) auto

Re: Cast a struct to void*

2015-01-09 Thread John Colvin via Digitalmars-d-learn
On Friday, 9 January 2015 at 18:35:56 UTC, anonymous wrote: On Friday, 9 January 2015 at 18:25:42 UTC, John Colvin wrote: struct S { void* p; } void main() { S s; auto a = cast(void*)s; //Error: e2ir: cannot cast s of type S to type void* } Is there are a good reason for this being

Re: Tuples not working?

2015-01-09 Thread Ali Çehreli via Digitalmars-d-learn
On 01/09/2015 10:42 AM, Jonathan Marler wrote: import std.stdio; import std.typecons; void main() { alias TL = Tuple!(int, long, float); foreach (i, T; TL) writefln(TL[%d] = %s, i, typeid(T)); } Why is this not working? D:\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(419):

Re: Cast a struct to void*

2015-01-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/9/15 1:50 PM, John Colvin wrote: On Friday, 9 January 2015 at 18:35:56 UTC, anonymous wrote: On Friday, 9 January 2015 at 18:25:42 UTC, John Colvin wrote: struct S { void* p; } void main() { S s; auto a = cast(void*)s; //Error: e2ir: cannot cast s of type S to type void* This

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread Robert burner Schadek via Digitalmars-d-learn
On Friday, 9 January 2015 at 14:03:21 UTC, ketmar via Digitalmars-d-learn wrote: std.regex can use CTFE to compile regular expressions (yet it sometimes slower than non-CTFE variant), and i mean that we compile regexp before doing alot of searches, not before each single search. if you have

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread ketmar via Digitalmars-d-learn
On Fri, 09 Jan 2015 14:11:49 + Robert burner Schadek via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 9 January 2015 at 14:03:21 UTC, ketmar via Digitalmars-d-learn wrote: std.regex can use CTFE to compile regular expressions (yet it sometimes slower

For those ready to take the challenge

2015-01-09 Thread eles via Digitalmars-d-learn
https://codegolf.stackexchange.com/questions/44278/debunking-stroustrups-debunking-of-the-myth-c-is-for-large-complicated-pro

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread Robert burner Schadek via Digitalmars-d-learn
On Friday, 9 January 2015 at 13:25:17 UTC, ketmar via Digitalmars-d-learn wrote: if you *really* concerned with speed here, you'd better consider using regular expressions. as regular expression can be precompiled and then search for multiple words with only one pass over the source string. i

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread ketmar via Digitalmars-d-learn
On Fri, 09 Jan 2015 13:54:00 + Robert burner Schadek via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 9 January 2015 at 13:25:17 UTC, ketmar via Digitalmars-d-learn wrote: if you *really* concerned with speed here, you'd better consider using regular

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread FrankLike via Digitalmars-d-learn
be creative! ;-) import std.algorithm, std.stdio; void main () { string s = he is at plane; if (findAmong!((string a, string b) = b.canFind(a))([s], [home, office, sea, plane]).length) { writeln(got it!); } else { writeln(alas...); } } or: import

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread ketmar via Digitalmars-d-learn
On Fri, 09 Jan 2015 12:46:53 + FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: The code is the best,and it's better than indexOfAny in C#: import std.algorithm, std.stdio; void main () { auto places = [ home, office, sea,plane]; auto strWhere = He

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread FrankLike via Digitalmars-d-learn
On Friday, 9 January 2015 at 10:02:53 UTC, ketmar via Digitalmars-d-learn wrote: import std.algorithm, std.stdio; void main () { string s = he is at home; if ([home, office, sea, plane].canFind!((a, string b) = b.canFind(a))(s)) { writeln(got it!); } else {

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread ketmar via Digitalmars-d-learn
On Fri, 09 Jan 2015 13:06:09 + FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 9 January 2015 at 10:02:53 UTC, ketmar via Digitalmars-d-learn wrote: import std.algorithm, std.stdio; void main () { string s = he is at home; if

Re: Why do the same work about 'IndexOfAny' and 'indexOf' function?

2015-01-09 Thread Robert burner Schadek via Digitalmars-d-learn
On Friday, 9 January 2015 at 14:21:04 UTC, ketmar via Digitalmars-d-learn wrote: heh. regexps *are* fast enough. it's hard to beat well-optimised generated thingy on a complex grammar. ;-) I don't see your point, anyway I think he got his help or at least some help.