|
102 | 102 | from sage.misc.cachefunc import cached_function, cached_method |
103 | 103 |
|
104 | 104 |
|
105 | | -def pad_right(T, length, zero=0): |
106 | | - r""" |
107 | | - Pad ``T`` to the right by using ``zero`` to have |
108 | | - at least the given ``length``. |
109 | | -
|
110 | | - INPUT: |
111 | | -
|
112 | | - - ``T`` -- A tuple, list or other iterable |
113 | | -
|
114 | | - - ``length`` -- a nonnegative integer |
115 | | -
|
116 | | - - ``zero`` -- (default: ``0``) the elements to pad with |
117 | | -
|
118 | | - OUTPUT: |
119 | | -
|
120 | | - An object of the same type as ``T`` |
121 | | -
|
122 | | - EXAMPLES:: |
123 | | -
|
124 | | - sage: from sage.combinat.k_regular_sequence import pad_right |
125 | | - sage: pad_right((1, 2, 3), 10) |
126 | | - (1, 2, 3, 0, 0, 0, 0, 0, 0, 0) |
127 | | - sage: pad_right((1, 2, 3), 2) |
128 | | - (1, 2, 3) |
129 | | -
|
130 | | - TESTS:: |
131 | | -
|
132 | | - sage: pad_right([1, 2, 3], 10) |
133 | | - [1, 2, 3, 0, 0, 0, 0, 0, 0, 0] |
134 | | - """ |
135 | | - return T + type(T)(zero for _ in range(length - len(T))) |
136 | | - |
137 | | - |
138 | 105 | class kRegularSequence(RecognizableSeries): |
139 | 106 | def __init__(self, parent, mu, left=None, right=None): |
140 | 107 | r""" |
|
0 commit comments