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

Heinrich Apfelmus apfelmus at quantentunnel.de
Wed Jun 2 03:42:50 EDT 2010

Yitzchak Gale wrote:
> A chess board is only 8x8, so depending on your algorithms,
> a simple 2 dimensional list might be the fastest:
> [[Maybe Piece]]
> That also allows you to write simple, beautiful functional code, using
> the wide selection of list functions available in the Prelude
> and Data.List.
> 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.

Ironically, it appears to me that  Data.Map  is *easier* to use than an
association list [(a,b)] , mainly because there aren't many functions in
the Prelude for working with association lists.

Heinrich Apfelmus


More information about the Beginners mailing list