Non Negative Integers¶
-
sage.sets.non_negative_integers.
NonNegativeIntegers
¶ The enumerated set of non negative integers.
This class implements the set of non negative integers, as an enumerated set (see
InfiniteEnumeratedSets
).EXAMPLES:
sage: NN = NonNegativeIntegers() sage: NN Non negative integers sage: NN.cardinality() +Infinity sage: TestSuite(NN).run() sage: NN.list() Traceback (most recent call last): ... NotImplementedError: cannot list an infinite set sage: NN.element_class <... 'sage.rings.integer.Integer'> sage: it = iter(NN) sage: [next(it), next(it), next(it), next(it), next(it)] [0, 1, 2, 3, 4] sage: NN.first() 0
Currently, this is just a “facade” parent; namely its elements are plain Sage
Integers
withInteger Ring
as parent:sage: x = NN(15); type(x) <... 'sage.rings.integer.Integer'> sage: x.parent() Integer Ring sage: x+3 18
In a later version, there will be an option to specify whether the elements should have
Integer Ring
orNon negative integers
as parent:sage: NN = NonNegativeIntegers(facade = False) # todo: not implemented sage: x = NN(5) # todo: not implemented sage: x.parent() # todo: not implemented Non negative integers
This runs generic sanity checks on
NN
:sage: TestSuite(NN).run()
TODO: do not use
NN
any more in the doctests forNonNegativeIntegers
.