]> gitweb.factorcode.org Git - factor.git/blob - extra/24-game/24-game-docs.factor
Fixes #2966
[factor.git] / extra / 24-game / 24-game-docs.factor
1 USING: arrays help.markup help.syntax kernel math ;
2 IN: 24-game
3
4 HELP: 24-game
5 { $description "Starts the game!" }
6 { $examples
7     { $unchecked-example
8         "USE: 24-game"
9         "24-game"
10         "{ 8 2 1 2 }\n"
11         "Commands: { + - * / rot swap q }\n"
12         "swap\n"
13         "{ 8 2 2 1 }\n"
14         "Commands: { + - * / rot swap q }\n"
15         "-\n"
16         "{ 8 2 1 }\n"
17         "Commands: { + - * / rot swap q }\n"
18         "+\n"
19         "{ 8 3 }\n"
20         "Commands: { + - * / swap q }\n"
21         "*\n"
22         "You WON!"
23     }
24 } ;
25
26 HELP: make-24
27 { $values { "array" array } }
28 { $description
29     "Produces a vector with 4 integers. With the following condition: "
30     "If these integers were directly on the stack, one can process them into 24, "
31     "just using the provided commands and the 4 numbers. The Following are the "
32     "provided commands: "
33     { $link + } ", " { $link - } ", " { $link * } ", "
34     { $link / } ", " { $link swap } ", and " { $link rot } "."
35 }
36 { $examples
37     { $example
38         "USING: 24-game kernel sequences prettyprint ;"
39         "make-24 length 4 = ."
40         "t"
41     }
42     { $notes { $link makes-24? } " is used in " { $link makes-24? } "." }
43 } ;
44
45 HELP: makes-24?
46 { $values
47     { "a" integer }
48     { "b" integer }
49     { "c" integer }
50     { "d" integer }
51     { "?" boolean }
52 }
53 { $description
54     "Tells if it is possible to win 24-game with these integers."
55 } ;
56
57 ARTICLE: "24-game" "The Game of 24"
58 "A classic math game, where one attempts to create 24, by applying "
59 "arithmetical operations and some shuffle words to a stack of 4 numbers."
60 { $subsections
61     24-game
62     make-24
63     makes-24?
64 } ;
65 ABOUT: "24-game"