]> gitweb.factorcode.org Git - factor.git/commitdiff
Minor logical rearrangement
authorAaron Schaefer <aaron@elasticdog.com>
Thu, 7 May 2009 20:54:49 +0000 (16:54 -0400)
committerAaron Schaefer <aaron@elasticdog.com>
Thu, 7 May 2009 20:54:49 +0000 (16:54 -0400)
extra/poker/poker-docs.factor
extra/poker/poker.factor

index ad2131870e7e351221e64686937d758f37b57be9..ab0a59ed4f8a73cca2061d381ede0d2866f622c0 100644 (file)
@@ -12,6 +12,14 @@ HELP: <hand>
 }
 { $notes "Cards may be specified in any order. Hands are directly comparable to each other on the basis of their computed value. Two hands are considered equal when they would tie in a game (despite being composed of different cards)." } ;
 
+HELP: best-hand
+{ $values { "str" string } { "hand" "a new hand" } }
+{ $description "Creates a new poker hand containing the best possible combination of the cards specified in " { $snippet "str" } "." }
+{ $examples
+    { $example "USING: kernel poker prettyprint ;"
+        "\"AS KD JC KH 2D 2S KH\" best-hand >value ." "\"Full House\"" }
+} ;
+
 HELP: >cards
 { $values { "hand" "a hand" } { "str" string } }
 { $description "Outputs a string representation of a hand's cards." }
@@ -28,11 +36,3 @@ HELP: >value
         "\"AC KC QC JC TC\" <hand> >value ." "\"Straight Flush\"" }
 }
 { $notes "This should not be used as a basis for hand comparison." } ;
-
-HELP: best-hand
-{ $values { "str" string } { "hand" "a new hand" } }
-{ $description "Creates a new poker hand containing the best possible combination of the cards specified in " { $snippet "str" } "." }
-{ $examples
-    { $example "USING: kernel poker prettyprint ;"
-        "\"AS KD JC KH 2D 2S KH\" best-hand >value ." "\"Full House\"" }
-} ;
index a749be239b4c2d61d1e0376905c384d7e3f14e25..b7661b83dbf2a7ac4e96e51d2e8cbf04eb24842e 100644 (file)
@@ -188,16 +188,16 @@ M: hand equal?
 : <hand> ( str -- hand )
     parse-cards dup hand-value hand boa ;
 
+: best-hand ( str -- hand )
+    parse-cards 5 all-combinations
+    [ dup hand-value hand boa ] map infimum ;
+
 : >cards ( hand -- str )
     cards>> [ card>string ] map " " join ;
 
 : >value ( hand -- str )
     hand-rank VALUE_STR nth ;
 
-: best-hand ( str -- hand )
-    parse-cards 5 all-combinations
-    [ dup hand-value hand boa ] map infimum ;
-
 TUPLE: deck
     { cards sequence } ;