]> gitweb.factorcode.org Git - factor.git/blob - extra/combinators/tuple/tuple-docs.factor
db407cbd3896ff0348a95c84d9b03b4097d242a6
[factor.git] / extra / combinators / tuple / tuple-docs.factor
1 ! (c)2009 Joe Groff bsd license
2 USING: assocs classes help.markup help.syntax kernel math
3 quotations strings ;
4 IN: combinators.tuple
5
6 HELP: 2make-tuple
7 { $values
8     { "x" object } { "y" object } { "class" class } { "assoc" assoc }
9     { "tuple" tuple }
10 }
11 { $description "Constructs a " { $link tuple } " of " { $snippet "class" } " by calling the quotations making up the values of " { $snippet "assoc" } " on " { $snippet "x" } " and " { $snippet "y" } ", assigning the result of each call to the slot named by the corresponding key. The quotations must have the effect " { $snippet "( x y -- slot-value )" } ". The order in which the quotations are called is undefined." } ;
12
13 HELP: 3make-tuple
14 { $values
15     { "x" object } { "y" object } { "z" object } { "class" class } { "assoc" "a list of " { $link string } "/" { $link quotation } " pairs" }
16     { "tuple" tuple }
17 }
18 { $description "Constructs a " { $link tuple } " of " { $snippet "class" } " by calling the quotations making up the values of " { $snippet "assoc" } " on " { $snippet "x" } ", " { $snippet "y" } ", and " { $snippet "z" } ", assigning the result of each call to the slot named by the corresponding key. The quotations must have the effect " { $snippet "( x y z -- slot-value )" } ". The order in which the quotations are called is undefined." } ;
19
20 HELP: make-tuple
21 { $values
22     { "x" object } { "class" class } { "assoc" "a list of " { $link string } "/" { $link quotation } " pairs" }
23     { "tuple" tuple }
24 }
25 { $description "Constructs a " { $link tuple } " of " { $snippet "class" } " by calling the quotations making up the values of " { $snippet "assoc" } " on " { $snippet "x" } ", assigning the result of each call to the slot named by the corresponding key. The quotations must have the effect " { $snippet "( x -- slot-value )" } ". The order in which the quotations are called is undefined." }
26 { $examples
27     { $example
28         "USING: combinators.tuple math prettyprint ;"
29         "IN: scratchpad"
30         "TUPLE: demo x y z ;"
31         "5 demo {"
32         "   { \"x\" [ 10 + ] }"
33         "   { \"y\" [ 100 / ] }"
34         "} make-tuple ."
35         "T{ demo { x 15 } { y 1/20 } }"
36     }
37 } ;
38
39 HELP: nmake-tuple
40 { $values
41     { "class" class } { "assoc" "a list of " { $link string } "/" { $link quotation } " pairs" } { "n" integer }
42 }
43 { $description "Constructs a " { $link tuple } " of " { $snippet "class" } " by calling the quotations making up the values of " { $snippet "assoc" } " on the top " { $snippet "n" } " values on the datastack below " { $snippet "class" } ", assigning the result of each call to the slot named by the corresponding key. The order in which the quotations are called is undefined." } ;
44
45 { make-tuple 2make-tuple 3make-tuple nmake-tuple } related-words
46
47 ARTICLE: "combinators.tuple" "Tuple-constructing combinators"
48 "The " { $vocab-link "combinators.tuple" } " vocabulary provides combinators that construct " { $link tuple } " objects. These provide additional functionality above and beyond built-in " { $link "tuple-constructors" } "."
49 { $subsections
50     make-tuple
51     2make-tuple
52     3make-tuple
53     nmake-tuple
54 } ;
55
56 ABOUT: "combinators.tuple"