Knight's Challenge in D

bearophile bearophileHUGS at lycos.com
Wed Apr 2 09:46:59 PDT 2008


Chris Miller:

>> putr( map((int el){ return format("%2d", el);}, row).join("  ") );
>So does any of that have a practical application for D?

1) This is a D forum, and lot of people here like various languages. I like many languages. I don't think adding few extra lines in my post may hurt.
2) D is an evolving language, and new things may be added to it in the future. If you don't discuss things you only keep C/C++ as a reference, and you may end with a C++-like-only language.
3) I think functional programming will become more important in the future. The last version (the one starting with putr) is actual D code you can run with my D libs. It's hairy, so it shows why a better syntax is very useful for that kind of programming. AST macros may help there. There is an alternative syntax you can use, plus the map of std.algorithms of D 2.x, and the tools by downs, etc.


>I just didn't feel like writing a shell sort by insertion (which I have found to be the fastest for this particular data set) just then.<

Probably there are other ways to improve that (a priority queue? Fibonacci Heaps? etc), but fastSort is already written...


>I agree that the Perl version is more readable.  I just needed something in D, since I don't know Perl, nor do I have a Perl interpreter handy.  My D version also can handle variable sized boards, which the Perl version cannot.<

I think a better-looking (and higher-level) D version can be written.


>I did not feel like learning enough Perl to make it handle variable sized boards, either.<

I see, then you can translate that Perl code to Python instead to D ;-)


>I'm learning D.  It was a problem I was familiar with, so I made an implementation in the new language.  It was fun.<

Good :-)

Bye,
bearophile



More information about the Digitalmars-d mailing list