home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
programming
/
gofer_1
/
examples_Grundy
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
Text File
|
1993-03-08
|
213 b
|
11 lines
--- Grundy numbers
data Game = Moves [Game]
grundy :: Game -> Int
grundy (Moves gs) = least (\n -> and [n/=grundy g|g<-gs])
least p = x where x:_ = [ n | n <- [0 ..], p n ]
nim n = Moves [nim m|m<-[0..(n-1)]]