Re: For those ready to take the challenge

2015-01-10 Thread MattCoder 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 From the link: Let's show Stroustrup what small and readable program actually is. Alright, there are a lot a

Re: A nice D coding pattern

2014-11-25 Thread MattCoder via Digitalmars-d-learn
On Monday, 24 November 2014 at 22:50:33 UTC, bearophile wrote: And the @disable this() assures that a struct is correctly initialized by the constructor. In the statement: @disable this() May I understand that you're disabling the default constructor of the struct to use your own constructor?

Re: A nice D coding pattern

2014-11-25 Thread MattCoder via Digitalmars-d-learn
On Tuesday, 25 November 2014 at 13:56:23 UTC, bearophile wrote: Right. So the instance data of the struct is more likely correct when you call its methods. Thanks. - Well I'd like to see more of these tips. My current code in D looks like C++ and of course I sure that I'm not extracting the

Re: How to start with d lang.

2014-11-02 Thread MattCoder via Digitalmars-d-learn
On Sunday, 2 November 2014 at 20:49:00 UTC, Kornel wrote: What learning materials do you recommend ?? http://ddili.org/ders/d.en/ Matheus.

Re: Reflections on isPalindrome

2014-10-29 Thread MattCoder via Digitalmars-d-learn
On Tuesday, 28 October 2014 at 16:07:38 UTC, MachineCode wrote: I'm very surprise. If they either equal or fast sometimes the compiler did great optizations or it's just a multicore processor that's helping or what else? the first version (from your post, the one using ranges) change in each

Re: Reflections on isPalindrome

2014-10-28 Thread MattCoder via Digitalmars-d-learn
Hi, I don't know if I'm missing something but I did some tests with the popFront and popBack version: bool isPalindrome(R)(R range) if (isBidirectionalRange!(R)) { while (!range.empty){ if (range.front != range.back) return false; range.popFront();

Re: Reflections on isPalindrome

2014-10-28 Thread MattCoder via Digitalmars-d-learn
On Tuesday, 28 October 2014 at 11:48:37 UTC, MattCoder wrote: And in my benchmark test, the first version is 3x slower than the second one. I forgot to say that I'm compiling with DMD without any compiler hints/optimizations. Matheus.

Re: Reflections on isPalindrome

2014-10-28 Thread MattCoder via Digitalmars-d-learn
On Tuesday, 28 October 2014 at 13:30:05 UTC, Nordlöw wrote: On Tuesday, 28 October 2014 at 11:51:42 UTC, MattCoder wrote: I forgot to say that I'm compiling with DMD without any compiler hints/optimizations. Try compiling with DMD flag -release and perhaps also -release -noboundscheck to

Re: Reducing an array

2014-04-19 Thread MattCoder via Digitalmars-d-learn
On Friday, 18 April 2014 at 20:02:41 UTC, Tim Holzschuh via Digitalmars-d-learn wrote: Hi there, I try to remove all equal elements of an array, thus [2,2] -- [2]. I thought this maybe would be possible with std.algorithm.reduce, but at least the way I tried it doesn't work: arr.reduce(

Re: Reducing an array

2014-04-19 Thread MattCoder via Digitalmars-d-learn
On Saturday, 19 April 2014 at 17:12:10 UTC, Ali Çehreli wrote: On 04/19/2014 09:55 AM, MattCoder wrote: On Friday, 18 April 2014 at 20:02:41 UTC, Tim Holzschuh via Digitalmars-d-learn wrote: void main(){ int myfilter(int a){ static int[] b; That static variable makes this