# Ticket #10593: trac_10593.patch

File trac_10593.patch, 1.5 KB (added by aapitzsch, 12 years ago)
• ## sage/rings/contfrac.py

# HG changeset patch
# User André Apitzsch <andre.apitzsch@st.ovgu.de>
# Date 1294763122 -3600
# Node ID aeebef4bc7c1eaf62b24501d5238c8aa61bf1632
# Parent  553928e531411153987bd0a766cf22fdeac915d9
trac 10593: replace __getslice__

diff -r 553928e53141 -r aeebef4bc7c1 sage/rings/contfrac.py
 a Returns `n`-th term of the continued fraction. OUTPUT: - an integer - an integer or a a continued fraction EXAMPLES:: 292 sage: a[-1] 14 """ return self._x[n] def __getslice__(self, i, j): """ OUTPUT: - a continued fraction EXAMPLES:: sage: a = continued_fraction(pi); a [3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14] sage: a[2:5] [15, 1, 292] sage: a[:3] [3, 7, 15] sage: a[4:] [292, 1, 1, 1, 2, 1, 3, 1, 14] sage: a[4::2] [292, 1, 2, 3, 14] """ return ContinuedFraction(self.parent(), self._x[i:j]) if isinstance(n, slice): start, stop, step = n.indices(len(self)) return ContinuedFraction(self.parent(), self._x[start:stop:step]) else: return self._x[n] def _repr_(self): """