[Haskell-cafe] newbie question on ordering
Joe Thornber
joe.thornber at gmail.com
Mon Apr 23 08:33:11 EDT 2007
On 22/04/07, Nikolay Metchev <nikolaymetchev at gmail.com> wrote:
> Hello guys,
> I have decided to try and get back into Haskell recently. I have used it in
> the past but have forgotten large chunks.
> I am trying to express the logic of a particular card game. For this purpose
> I need to be able to order cards in various orders. At first I thought that
> the Ord class was my answer but I found it very verbose. Below is my best
> attempt so far but I can't help but feel it too is verbose and that there
> must be a better way of comparing cards in different orders.
I wrote some code for comparing poker hands that you may find useful
[1]. It gives each hand a classification, and then orders first on
the classification, and then on some secondary property of the
classification (eg, highest card in hand).
- Joe
[1] http://www.lambda-software.com/darcs/programming-challenges/2.8.2/poker.hs
More information about the Haskell-Cafe
mailing list