]> gitweb.factorcode.org Git - factor.git/commitdiff
Link ?first ?second ?last from an article.
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 13 Oct 2011 22:53:31 +0000 (15:53 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 13 Oct 2011 22:53:31 +0000 (15:53 -0700)
core/sequences/sequences-docs.factor

index 5c68a55873e96c669c56604d05032c9136b81cfd..e17cdc9eb87a49963f3194bef30a32687c9e939d 100644 (file)
@@ -181,7 +181,20 @@ HELP: ?nth
 
 HELP: ?first
 { $values { "seq" sequence } { "elt/f" "an object or " { $link f } } }
-{ $description "A forgiving version of " { $link first } ". If the sequence is empty, or if the sequence is " { $link f } ", simply outputs " { $link f } "." } ;
+{ $description "A forgiving version of " { $link first } ". If the sequence is empty, or if the sequence is " { $link f } ", simply outputs " { $link f } "." }
+{ $examples
+    "On an empty sequence:"
+    { $example "USING: sequences prettyprint ;"
+               "{ } ?first ."
+               "f"
+    }
+    "Works like first on sequences with elements:"
+    { $example "USING: sequences prettyprint ;"
+               "{ 1 2 3 } ?first ."
+               "1"
+    }
+} ;
+
 
 HELP: ?second
 { $values { "seq" sequence } { "elt/f" "an object or " { $link f } } }
@@ -1466,9 +1479,9 @@ ARTICLE: "sequences-access" "Accessing sequence elements"
 "Element access by index, without raising exceptions:"
 { $subsections ?nth }
 "Concise way of extracting one of the first four elements:"
-{ $subsections first second third fourth }
+{ $subsections first second third fourth ?first ?second }
 "Extracting the last element:"
-{ $subsections last }
+{ $subsections last ?last }
 "Unpacking sequences:"
 { $subsections first2 first3 first4 }
 { $see-also nth } ;