]> gitweb.factorcode.org Git - factor.git/commitdiff
Speed up best-hand by not converting to ckf repeatedly
authorAaron Schaefer <aaron@elasticdog.com>
Thu, 7 May 2009 14:29:44 +0000 (10:29 -0400)
committerAaron Schaefer <aaron@elasticdog.com>
Thu, 7 May 2009 14:29:44 +0000 (10:29 -0400)
extra/poker/poker.factor

index df8d93d9fa352e627fa382244e6551b2b449930c..a749be239b4c2d61d1e0376905c384d7e3f14e25 100644 (file)
@@ -195,7 +195,8 @@ M: hand equal?
     hand-rank VALUE_STR nth ;
 
 : best-hand ( str -- hand )
-    " " split 5 all-combinations [ " " join <hand> ] map infimum ;
+    parse-cards 5 all-combinations
+    [ dup hand-value hand boa ] map infimum ;
 
 TUPLE: deck
     { cards sequence } ;