Bases: sage.structure.unique_representation.UniqueRepresentation, sage.structure.parent.Parent
An example of infinite enumerated set: the non negative integers
This class provides a minimal implementation of an infinite enumerated set.
EXAMPLES:
sage: NN = InfiniteEnumeratedSets().example()
sage: NN
An example of an infinite enumerated set: the non negative integers
sage: NN.cardinality()
+Infinity
sage: NN.list()
...
NotImplementedError: infinite list
sage: NN.element_class
<type 'sage.rings.integer.Integer'>
sage: it = iter(NN)
sage: [it.next(), it.next(), it.next(), it.next(), it.next()]
[0, 1, 2, 3, 4]
sage: x = it.next(); type(x)
<type 'sage.rings.integer.Integer'>
sage: x.parent()
Integer Ring
sage: x+3
8
sage: NN(15)
15
sage: NN.first()
0
This checks that the different methods of return consistent results:
sage: TestSuite(NN).run(verbose = True)
running ._test_an_element() . . . pass
running ._test_category() . . . pass
running ._test_elements() . . .
Running the test suite of self.an_element()
running ._test_category() . . . pass
running ._test_eq() . . . pass
running ._test_not_implemented_methods() . . . pass
running ._test_pickling() . . . pass
pass
running ._test_elements_eq() . . . pass
running ._test_enumerated_set_contains() . . . pass
running ._test_enumerated_set_iter_cardinality() . . . pass
running ._test_enumerated_set_iter_list() . . . pass
running ._test_eq() . . . pass
running ._test_not_implemented_methods() . . . pass
running ._test_pickling() . . . pass
running ._test_some_elements() . . . pass
EXAMPLES:
sage: InfiniteEnumeratedSets().example().an_element()
42
EXAMPLES:
sage: NN = InfiniteEnumeratedSets().example()
sage: NN.next(3)
4