Paste: Poker Hands Benchmark
Author: | elasticdog |
Mode: | factor |
Date: | Sat, 20 Feb 2010 19:17:23 |
Plain Text |
USING: accessors arrays formatting fry kernel math math.combinatorics poker
poker.private sequences sequences.product ;
IN: benchmark.poker-hands
<PRIVATE
: print-frequency ( seq -- )
[ [ VALUE_STR nth swap "%15s: %d\n" printf ] each-index ] keep
sum [ "" "TOTAL" ] dip "%'=25s\n%15s: %d\n" printf ;
PRIVATE>
: poker-hands ( -- )
<deck> 5 9 0 <array> [
'[ hand-value value>rank _ [ 1 + ] change-nth ] each-combination
] keep print-frequency ;
MAIN: poker-hands
New Annotation