Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: The Glory that is ML (long and not for the faint of heart)

Author: Anthony Cozzie

Date: 10:31:20 08/01/03

Go up one level in this thread


>AFAIK, ML stands for "meta language", since the intended application
>was a proof system.

yep.  The guy who invented ML is a professor at CMU, so we all have to learn it.
 A lot of the C hackers really suffer in 15-212.

>>structure Regex :> REGEX =
>>struct
>>  datatype regExp =
>>    Char of char
>>  | Concat of regExp * regExp
>>  | Epsilon
>>  | Union of regExp * regExp
>>  | Empty
>>  | Star of regExp
>>  | Underscore (matches anything)
>>  | And of regExp * regExp
>>  | Top
>>  | Not of regExp
>>
>>  fun acc (Char(a)) (nil) k = false
>>     |acc (Char(a)) (b::s) k = if a = b then k s else false
>>     |acc (Epsilon) s k = k s
>>     |acc (Empty) s k = false
>>     |acc (Union(r1,r2)) s k = acc r1 s k orelse acc r2 s k
>>     |acc (Concat(r1,r2)) s k = acc r1 s (fn s' => acc r2 s' k)
>>     |acc (r as Star(r1)) s k = k s orelse acc r1 s (fn s' => if s = s' then fal
>>se else acc r s' k)
>>     |acc (Underscore) (nil) k = false
>>     |acc (Underscore) (b::s) k = k s
>>     |acc (And(r1,r2)) s k = acc r1 s k andalso acc r2 s k
>>     |acc (Top) s k = acc (Star(Underscore)) s k
>>     |acc (Not(r)) s k = if (acc r s (fn s' => if (k s) then false else true) th
>>en false else true
>>
>>  fun accept r s = acc r (String.explode s) (fn nil => true | x => false)
>>end

Its been a while since I took 212, but I seem to remember that AND, TOP, and NOT
were extra credit, and I only got credit for Top.

>I have used SML for one of the most complicated programs I've ever written
>(about "busy beaver").  Before using SML, I failed (!) to do it in C++.
>Somehow the virtual destructors managed to be wrong, sometimes.
>Here garbage collection was a _huge_ plus.
>
>OTOH, I wouldn't use ML for a chess program.  Maybe when I become more
>experienced with it...

neither would I.  IMHO, C/C++ is the best language for chess programs, because
of the speed.  A chess program is small enough that it can be written well in C,
and if you get 2x the speed, your program is 50 ELO stronger, all other things
being equal.

anthony



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.