[Haskell-beginners] Re: Simple Chess Program for Learning FP

Christian Maeder Christian.Maeder at dfki.de
Wed Jun 2 07:07:48 EDT 2010

Yitzchak Gale schrieb:
> If you choose a map from positions to pieces, it might turn out
> to be just about as fast to use a simple association list
> [(Int, Int), Maybe Piece]
> instead of all the machinery of Data.Map.Map (Int, Int) (Maybe Piece)
> A chess board has only 64 locations.

if you associate positions to pieces, you can omit "Maybe" and simple
delete positions without pieces from the Map. So your Map will only have
32 entries or fewer.

Furthermore, you could code your row and column positions (r, c) as a
single Int p and use Data.IntMap.IntMap Piece.

p = 8 * r + c
c = mod p 8
r = div p 8

Have fun

More information about the Beginners mailing list