Class: Math::SetTheory::NaturalNumbers
- Includes:
- Singleton
- Defined in:
- lib/ruuuby/math/set_theory/discrete/natural_numbers.rb
Overview
also called: counting-numbers
Instance Attribute Summary
Attributes inherited from NumberSet
Attributes inherited from Closure
Instance Method Summary collapse
-
#_β?(n) ⇒ Boolean
True.
-
#initialize ⇒ NaturalNumbers
constructor
A new instance of NaturalNumbers.
Methods inherited from NumberSet
#countable?, #countably_infinite?, #finite?, #uncountable?, #β?, #β?, #β?, #β?, #β?, #β ?, #β?, #β?
Constructor Details
#initialize ⇒ NaturalNumbers
Returns a new instance of NaturalNumbers.
11 12 13 14 15 16 17 |
# File 'lib/ruuuby/math/set_theory/discrete/natural_numbers.rb', line 11 def initialize super(:β, ::Math::SetTheory::NumberSet::AlephNumbers::ZERO, { closed_under_addition: true, closed_under_multiplication: true }) @subset_of = [:π, :πΈα΅£, :πΈ, :β, :β, :β, :β€, :π] end |
Instance Method Details
#_β?(n) ⇒ Boolean
Returns true.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ruuuby/math/set_theory/discrete/natural_numbers.rb', line 20 def _β?(n) if n.zero? false else case(n) when ::Integer n > 0 when ::Float ((!(n.β? || n.negative?)) && (n.positive? && n.smells_like_int?)) when ::BigDecimal case(n.sign) when ::BigDecimal::SIGN_NaN, ::BigDecimal::SIGN_POSITIVE_INFINITE, ::BigDecimal::SIGN_NEGATIVE_INFINITE, ::BigDecimal::SIGN_NEGATIVE_FINITE, ::BigDecimal::SIGN_POSITIVE_ZERO, ::BigDecimal::SIGN_NEGATIVE_ZERO false else n.smells_like_int? end when ::Complex n.imaginary == 0 && β.β?(n.real) when ::Rational β.β?(n.numerator) && β.β?(n.denominator) else false end end end |