]> gitweb.factorcode.org Git - factor.git/commitdiff
combinators.tuple-docs: add example code for make-tuple
authorAlexander Iljin <ajsoft@yandex.ru>
Tue, 1 Nov 2016 22:56:18 +0000 (01:56 +0300)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 2 Nov 2016 15:01:26 +0000 (08:01 -0700)
extra/combinators/tuple/tuple-docs.factor

index 3fea71149abccccdb6d42b0ef5d4b890d38810dc..db407cbd3896ff0348a95c84d9b03b4097d242a6 100644 (file)
@@ -22,7 +22,19 @@ HELP: make-tuple
     { "x" object } { "class" class } { "assoc" "a list of " { $link string } "/" { $link quotation } " pairs" }
     { "tuple" tuple }
 }
-{ $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." } ;
+{ $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." }
+{ $examples
+    { $example
+        "USING: combinators.tuple math prettyprint ;"
+        "IN: scratchpad"
+        "TUPLE: demo x y z ;"
+        "5 demo {"
+        "   { \"x\" [ 10 + ] }"
+        "   { \"y\" [ 100 / ] }"
+        "} make-tuple ."
+        "T{ demo { x 15 } { y 1/20 } }"
+    }
+} ;
 
 HELP: nmake-tuple
 { $values