Skip to content

Commit be462dc

Browse files
committed
Trac #21203 review issue 3: example for __getitem__ and __iter__
1 parent a6a8c3b commit be462dc

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/sage/combinat/k_regular_sequence.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,23 @@ def __init__(self, parent, mu, left=None, right=None):
127127
EXAMPLES::
128128
129129
sage: Seq2 = kRegularSequenceSpace(2, ZZ)
130-
sage: Seq2((Matrix([[3, 6], [0, 1]]), Matrix([[0, -6], [1, 5]])),
131-
....: vector([0, 1]), vector([1, 0])).transposed()
130+
sage: S = Seq2((Matrix([[3, 6], [0, 1]]), Matrix([[0, -6], [1, 5]])),
131+
....: vector([0, 1]), vector([1, 0])).transposed(); S
132132
2-regular sequence 0, 1, 3, 5, 9, 11, 15, 19, 27, 29, ...
133133
134+
We can access the coefficients of a sequence by
135+
::
136+
137+
sage: S[5]
138+
11
139+
140+
or iterating over the first, say `10`, by
141+
::
142+
143+
sage: from itertools import islice
144+
sage: list(islice(S, 10))
145+
[0, 1, 3, 5, 9, 11, 15, 19, 27, 29]
146+
134147
.. SEEALSO::
135148
136149
:doc:`k-regular sequence <k_regular_sequence>`,

0 commit comments

Comments
 (0)