The Natural module attempts to provide a representation of natural numbers (non-positive integers) which behave as much as possible like normal Integers. All calculations which would normally return a negative number result in an Indeterminate value. Once a Natural becomes Indeterminate, it will remain indeterminate in subsequent calculations. Such a calculation has, in effect, been errored-out in a safe manner.
This is not a type-level representation of naturals as in some packages. It is basically a wrapper around the Integer type, using pattern-based rewriting.
Naturals are created with the safe constructors natural or indeterm. Note that for practical reasons Indeterminate values are considered equal, which allows easy detection of an errored-out calculation via comparison.
Feel free to send me an e-mail if you find the package useful, or if you have any suggestions or code to share.
Constructs a Natural number, which is defined here as all non-negative integers, including zero. Passing in a negative integer will result in an Indeterminate value.
natural 10Natural 10
natural 0Natural 0