]> gitweb.factorcode.org Git - factor.git/blob - basis/persistent/sequences/sequences-docs.factor
Merge branch 'master' into experimental (untested!)
[factor.git] / basis / persistent / sequences / sequences-docs.factor
1 IN: persistent.sequences
2 USING: help.markup help.syntax math sequences kernel ;
3
4 HELP: new-nth
5 { $values { "val" object } { "i" integer } { "seq" sequence } { "seq'" sequence } }
6 { $contract "Persistent analogue of " { $link set-nth } ". Outputs a new sequence with the " { $snippet "i" } "th element replaced by " { $snippet "val" } "." } ;
7
8 HELP: ppush
9 { $values { "val" object } { "seq" sequence } { "seq'" sequence } }
10 { $contract "Persistent analogue of " { $link push } ". Outputs a new sequence with all elements of " { $snippet "seq" } " together with " { $snippet "val" } " added at the end." } ;
11
12 HELP: ppop
13 { $values { "seq" sequence } { "seq'" sequence } }
14 { $contract "Persistent analogue of " { $link pop* } ". Outputs a new sequence with all elements of " { $snippet "seq" } " except for the final element." } ;
15
16 ARTICLE: "persistent.sequences" "Persistent sequence protocol"
17 "The persistent sequence protocol consists of the non-mutating sequence protocol words, such as  " { $link length } " and " { $link nth } ", together with the following operations:"
18 { $subsection new-nth }
19 { $subsection ppush }
20 { $subsection ppop }
21 "The default implementations of the above run in " { $snippet "O(n)" } " time; the " { $vocab-link "persistent.vectors" } " vocabulary provides an implementation of these operations in " { $snippet "O(1)" } " time." ;
22
23 ABOUT: "persistent.sequences"