Re: Are there any exercises/challenges for D?

2014-08-26 Thread bearophile via Digitalmars-d-learn

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


Re: Are there any exercises/challenges for D?

2014-08-25 Thread Meta via Digitalmars-d-learn

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;
}


Re: Are there any exercises/challenges for D?

2014-08-25 Thread Meta via Digitalmars-d-learn

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;
}


Re: Are there any exercises/challenges for D?

2014-08-24 Thread bearophile via Digitalmars-d-learn

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


Re: Are there any exercises/challenges for D?

2014-08-24 Thread Weaseldog via Digitalmars-d-learn

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 ;)


Re: Are there any exercises/challenges for D?

2014-08-24 Thread maik klein via Digitalmars-d-learn

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.




Re: Are there any exercises/challenges for D?

2014-08-24 Thread via Digitalmars-d-learn

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.


Re: Are there any exercises/challenges for D?

2014-08-24 Thread Ola Fosheim Gr via Digitalmars-d-learn
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?


Re: Are there any exercises/challenges for D?

2014-08-24 Thread bearophile via Digitalmars-d-learn

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