]> gitweb.factorcode.org Git - factor.git/blob - core/collections/virtual-sequences.facts
more sql changes
[factor.git] / core / collections / virtual-sequences.facts
1 USING: help sequences ;
2
3 HELP: reversed
4 { $class-description "A virtual sequence which presents a reversed view of an underlying sequence." }
5 { $see-also <reversed> reverse } ;
6
7 HELP: reversed@
8 { $values { "m" "a non-negative integer" } { "reversed" "an instance of " { $link reversed } } { "n" "a non-negative integer" } { "seq" "a sequence" } }
9 { $description "Indexes into a reversed sequence. Helper word used to implement " { $link "sequence-protocol" } " methods for the " { $link reversed } " class." } ;
10
11 HELP: reverse
12 { $values { "seq" "a sequence" } { "newseq" "a new sequence" } }
13 { $description "Outputs a new sequence having the same elements as " { $snippet "seq" } " but in reverse order." } ;
14
15 HELP: <reversed> ( seq -- reversed )
16 { $values { "seq" "a sequence" } { "reversed" "a new sequence" } }
17 { $description "Creates an instance of the " { $link reversed } " virtual sequence." } ;
18
19 HELP: slice-error
20 { $values { "str" "a reason" } }
21 { $description "Throws a " { $link slice-error } "." }
22 { $error-description "Thrown by " { $link <slice> } " if one of the following invalid conditions holds:"
23     { $list
24         "The start index is negative"
25         "The end index is greater than the length of the sequence"
26         "The start index is greater than the end index"
27     }
28 } ;
29
30 HELP: slice
31 { $class-description "A virtual sequence which presents a subrange of the elements of an underlying sequence." }
32 { $see-also <slice> subseq } ;
33
34 HELP: <slice>
35 { $values { "m" "a non-negative integer" } { "n" "a non-negative integer" } { "seq" "a sequence" } { "slice" "a slice" } }
36 { $description "Outputs a new virtual sequence sharing storage with the subrange of elements in " { $snippet "seq" } " with indices starting from and including " { $snippet "m" } ", and up to but not including " { $snippet "n" } "." }
37 { $errors "Throws an error if " { $snippet "m" } " or " { $snippet "n" } " is out of bounds." } ;
38
39 HELP: slice@
40 { $values { "m" "a non-negative integer" } { "slice" "an instance of " { $link slice } } { "n" "a non-negative integer" } { "seq" "a sequence" } }
41 { $description "Indexes into a slice. Helper word used to implement " { $link "sequence-protocol" } " methods for the " { $link reversed } " class." } ;
42
43 HELP: column
44 { $class-description "A virtual sequence which presents a fixed column of a matrix represented as a sequence of rows." }
45 { $see-also <column> } ;
46
47 HELP: <column>
48 { $values { "seq" "a sequence" } { "n" "a non-negative integer" } }
49 { $description "Outputs a new virtual sequence which presents a fixed column of a matrix represented as a sequence of rows." "The " { $snippet "i" } "th element of a column is the " { $snippet "n" } "th element of the " { $snippet "i" } "th element of" { $snippet "seq" } ". Every element of " { $snippet "seq" } " must be a sequence, and all sequences must have equal length." }
50 { $examples
51     { $example
52         "{ { 1 2 3 } { 4 5 6 } { 7 8 9 } } 0 <column> >array ."
53         "{ 1 4 7 }"
54     }
55 }
56 { $notes
57     "In the same sense that " { $link <reversed> } " is a virtual variant of " { $link reverse } ", " { $link <column> } " is a virtual variant of " { $snippet "[ swap nth ] map-with" } "."
58 } ;
59
60 HELP: column@
61 { $values { "m" "a non-negative integer" } { "column" "an instance of " { $link column } } { "n" "a non-negative integer" } { "seq" "a sequence" } }
62 { $description "Indexes into a column view of a matrix. Helper word used to implement " { $link "sequence-protocol" } " methods for the " { $link column } " class." } ;