Pattern matching example

bearophile bearophileHUGS at lycos.com
Sat Apr 3 17:44:29 PDT 2010


I'm not currently asking to implement pattern matching in D3 (as present for example in Scala), but it's positive to think how to solve similar problems in D2, because even if pattern matching is not available in D2, the problems it is asked to solve solve can be real.

Walter or Andrei has recently shown here a possible implementation idea, but I don't remember where the post is and what the implementation was. And it wasn't a small compilable program.

Recently the RosettaCode site has added a small but real problem to solve with pattern matching. It can be a quite good example to see how D2 can be used solve this problem:

http://rosettacode.org/wiki/Pattern_matching

RosettaCode site is nice, because among its various purposes, it can be advertisement too for the D language. That's why I (and Downs and probably others here) have written many solutions in D1/D2 for that site. So I even suggest to put a link to to RosettaCode somewhere in the D section of the digitalmars site, to turn it into a semi-official thing.

Bye,
bearophile



More information about the Digitalmars-d mailing list