make >ckf generic in poker

db4
Doug Coleman 2009-11-28 19:12:45 -06:00
parent 2d21f3bdd3
commit 57264bb0e1
1 changed files with 6 additions and 4 deletions

View File

@ -5,7 +5,7 @@
USING: accessors arrays ascii assocs binary-search combinators
fry kernel locals math math.bitwise math.combinatorics
math.order math.statistics poker.arrays random sequences
sequences.product splitting grouping lexer ;
sequences.product splitting grouping lexer strings ;
IN: poker
! The algorithm used is based on Cactus Kev's Poker Hand Evaluator with
@ -110,9 +110,11 @@ CONSTANT: VALUE_STR { "Straight Flush" "Four of a Kind" "Full House" "Flush"
:: (>ckf) ( rank suit -- n )
rank rank suit rank card-bitfield ;
: >ckf ( string -- n )
#! Cactus Kev Format
>upper 1 cut (>ckf) ;
#! Cactus Kev Format
GENERIC: >ckf ( string -- n )
M: string >ckf >upper 1 cut (>ckf) ;
M: integer >ckf ;
: parse-cards ( string -- seq )
" " split [ >ckf ] map ;