www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Are there any exercises/challenges for D?

reply "maik klein" <maikklein googlemail.com> writes:
Are there any exercises/challenges for D?

Something like this? 
http://www.haskell.org/haskellwiki/99_questions/1_to_10
Aug 24 2014
next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
maik klein:

 Are there any exercises/challenges for D?

 Something like this? 
 http://www.haskell.org/haskellwiki/99_questions/1_to_10
This is an interesting question. There are many exercises/challenges that can be done in D, but I don't know any specific for D. As D challenge I suggest to write a useful Phobos pull request, there are many many missing useful functions. Bye, bearophile
Aug 24 2014
prev sibling next sibling parent reply "Weaseldog" <weaseldog gmail.com> writes:
On Sunday, 24 August 2014 at 20:32:02 UTC, maik klein wrote:
 Are there any exercises/challenges for D?

 Something like this? 
 http://www.haskell.org/haskellwiki/99_questions/1_to_10
Well, you could port 99 lisp problems to D - D can be written in a fairly functional style ;)
Aug 24 2014
parent reply "maik klein" <maikklein googlemail.com> writes:
On Sunday, 24 August 2014 at 21:51:39 UTC, Weaseldog wrote:
 On Sunday, 24 August 2014 at 20:32:02 UTC, maik klein wrote:
 Are there any exercises/challenges for D?

 Something like this? 
 http://www.haskell.org/haskellwiki/99_questions/1_to_10
Well, you could port 99 lisp problems to D - D can be written in a fairly functional style ;)
I am just trying to learn D by writing code. Of course I could just do them in D but I would like to compare my version with idiomatic D. It's actually quite strange that no one has done something like this in D, it's usually the first thing people do.
Aug 24 2014
next sibling parent reply "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
On Sunday, 24 August 2014 at 23:20:21 UTC, maik klein wrote:
 It's actually quite strange that no one has done something like 
 this in D, it's usually the first thing people do.
Bearophile has created many such examples at Rosettacode.
Aug 24 2014
next sibling parent "Ola Fosheim Gr" <ola.fosheim.grostad+dlang gmail.com> writes:
On Sunday, 24 August 2014 at 23:36:55 UTC, Ola Fosheim Grøstad 
wrote:
 On Sunday, 24 August 2014 at 23:20:21 UTC, maik klein wrote:
 It's actually quite strange that no one has done something 
 like this in D, it's usually the first thing people do.
Bearophile has created many such examples at Rosettacode.
http://rosettacode.org/wiki/Category:D Pretty long list of tasks?
Aug 24 2014
prev sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Ola Fosheim Grøstad:

 Bearophile has created many such examples at Rosettacode.
I am updating and improving them, but I have created only a percentage of them (60-70%? I don't know). Bye, bearophile
Aug 24 2014
prev sibling parent reply "Meta" <jared771 gmail.com> writes:
On Sunday, 24 August 2014 at 23:20:21 UTC, maik klein wrote:
 On Sunday, 24 August 2014 at 21:51:39 UTC, Weaseldog wrote:
 On Sunday, 24 August 2014 at 20:32:02 UTC, maik klein wrote:
 Are there any exercises/challenges for D?

 Something like this? 
 http://www.haskell.org/haskellwiki/99_questions/1_to_10
Well, you could port 99 lisp problems to D - D can be written in a fairly functional style ;)
I am just trying to learn D by writing code. Of course I could just do them in D but I would like to compare my version with idiomatic D. It's actually quite strange that no one has done something like this in D, it's usually the first thing people do.
Have you heard of Project Euler? https://projecteuler.net/ The problems are mostly mathematical, and once you answer you can compare your solution to the other solutions people have written in other languages. The early questions also have some very unique and beautiful range-based D solutions. import std.algorithm; import std.range; import std.stdio; alias fold = std.functional.binaryReverseArgs!(reduce!((n1, n2) => n1 + n2)); enum limit = 4_000_000; void main() { recurrence!q{a[n-1] + a[n-2]}(1, 1) .take(1000) .filter!(n => n >= 0 && n < limit && n % 2 == 0) .sum.writeln; }
Aug 25 2014
parent "Meta" <jared771 gmail.com> writes:
On Tuesday, 26 August 2014 at 01:57:06 UTC, Meta wrote:
 Have you heard of Project Euler? https://projecteuler.net/

 The problems are mostly mathematical, and once you answer you 
 can compare your solution to the other solutions people have 
 written in other languages. The early questions also have some 
 very unique and beautiful range-based D solutions.

 import std.algorithm;
 import std.range;
 import std.stdio;

 alias fold = std.functional.binaryReverseArgs!(reduce!((n1, n2) 
 => n1 + n2));
 enum limit = 4_000_000;

 void main()
 {
     recurrence!q{a[n-1] + a[n-2]}(1, 1)
         .take(1000)
         .filter!(n => n >= 0 && n < limit && n % 2 == 0)
         .sum.writeln;
 }
Whoops, wrong code. Also, this is the answer to PE problem 2. import std.algorithm; import std.range; import std.stdio; enum limit = 4_000_000; void main() { recurrence!q{a[n-1] + a[n-2]}(1, 1) .take(1000) .filter!(n => n >= 0 && n < limit && n % 2 == 0) .sum .writeln; }
Aug 25 2014
prev sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
maik klein:

 Are there any exercises/challenges for D?
Some exercises here: http://rosettacode.org/wiki/Reports:Tasks_not_implemented_in_D Please announce them here when you solve some of them :-) Bye, bearophile
Aug 26 2014