]> gitweb.factorcode.org Git - factor.git/blob - extra/24-game/24-game-docs.factor
Remove stack effects from HELP: declarations.
[factor.git] / extra / 24-game / 24-game-docs.factor
1 USING: help.markup help.syntax math kernel ;
2 IN: 24-game
3
4 HELP: play-game
5 { $description "Starts the game!" }
6 { $examples
7     { $unchecked-example
8         "USE: 24-game"
9         "play-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: 24-able
27 { $values { "vector" "vector of 4 integers" } }
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         "24-able length 4 = ."
40         "t"
41     }
42     { $notes { $link 24-able? } " is used in " { $link 24-able } "." }
43 } ;
44
45 HELP: 24-able?
46 { $values
47     { "quad" "vector of 4 integers" }
48     { "t/f" "a boolean" }
49 }
50 { $description
51     "Tells if it is possible to win 24-game if it was initiated "
52     "with this sequence."
53 } ;
54
55 HELP: build-quad
56 { $values
57     { "array" "an array of 4 numbers" }
58 }
59 { $description "Builds an array of 4 random numbers." } ;
60 ARTICLE: "24-game" "The Game of 24"
61 "A classic math game, where one attempts to create 24, by applying "
62 "arithmetical operations and some shuffle words to a stack of 4 numbers. "
63 { $subsections
64     play-game
65     24-able
66     24-able?
67     build-quad
68 } ;
69 ABOUT: "24-game"