pub enum Digit {
Neg,
Zero,
Pos,
}Expand description
Represents a digit in the balanced ternary numeral system.
A digit can have one of three values:
Neg(-1): Represents the value -1 in the balanced ternary system.Zero(0): Represents the value 0 in the balanced ternary system.Pos(+1): Represents the value +1 in the balanced ternary system.
Provides utility functions for converting to/from characters, integers, and negation.
Variants§
Implementations§
Source§impl Digit
impl Digit
Sourcepub fn to_char(&self) -> char
pub fn to_char(&self) -> char
Converts the Digit into its character representation.
- Returns:
-forDigit::Neg0forDigit::Zero+forDigit::Pos
Sourcepub fn from_char(c: char) -> Digit
pub fn from_char(c: char) -> Digit
Creates a Digit from its character representation.
- Accepts:
-forDigit::Neg0forDigit::Zero+forDigit::Pos
- Panics if the input character is invalid.
Sourcepub fn to_i8(&self) -> i8
pub fn to_i8(&self) -> i8
Converts the Digit into its integer representation.
- Returns:
- -1 for
Digit::Neg - 0 for
Digit::Zero - 1 for
Digit::Pos
- -1 for
Sourcepub fn from_i8(i: i8) -> Digit
pub fn from_i8(i: i8) -> Digit
Creates a Digit from its integer representation.
- Accepts:
- -1 for
Digit::Neg - 0 for
Digit::Zero - 1 for
Digit::Pos
- -1 for
- Panics if the input integer is invalid.
Sourcepub fn possibly(&self) -> Self
pub fn possibly(&self) -> Self
Returns the corresponding possible value of the current Digit.
- Returns:
Digit::NegforDigit::NegDigit::PosforDigit::ZeroDigit::PosforDigit::Pos
Sourcepub fn necessary(&self) -> Self
pub fn necessary(&self) -> Self
Determines the condition of necessity for the current Digit.
- Returns:
Digit::NegforDigit::NegDigit::NegforDigit::ZeroDigit::PosforDigit::Pos
This method is used to calculate necessity as part of balanced ternary logic systems.
Sourcepub fn contingently(&self) -> Self
pub fn contingently(&self) -> Self
Determines the condition of contingency for the current Digit.
- Returns:
Digit::NegforDigit::NegDigit::PosforDigit::ZeroDigit::NegforDigit::Pos
This method represents contingency in balanced ternary logic,
which defines the specific alternation of Digit values.
Sourcepub fn not_negative(&self) -> Self
pub fn not_negative(&self) -> Self
Determines the condition of non-negativity for the current Digit.
- Returns:
Digit::ZeroforDigit::NegDigit::PosforDigit::ZeroDigit::PosforDigit::Pos
This method is used to filter out negative conditions in computations with balanced ternary representations.
Sourcepub fn positive(&self) -> Self
pub fn positive(&self) -> Self
Determines the strictly positive condition for the current Digit.
- Returns:
Digit::ZeroforDigit::NegDigit::ZeroforDigit::ZeroDigit::PosforDigit::Pos
This method is used to calculate strictly positive states in association with ternary logic.
Sourcepub fn not_positive(&self) -> Self
pub fn not_positive(&self) -> Self
Determines the condition of non-positivity for the current Digit.
- Returns:
Digit::PosforDigit::NegDigit::PosforDigit::ZeroDigit::ZeroforDigit::Pos
This method complements the positive condition and captures
states that are not strictly positive.
Sourcepub fn negative(&self) -> Self
pub fn negative(&self) -> Self
Determines the strictly negative condition for the current Digit.
- Returns:
Digit::PosforDigit::NegDigit::ZeroforDigit::ZeroDigit::ZeroforDigit::Pos
This method calculates strictly negative states in association with ternary logic.
Sourcepub fn k3_imply(&self, other: Self) -> Self
pub fn k3_imply(&self, other: Self) -> Self
Performs Kleene implication with the current Digit as self and another Digit.
-
self: The antecedent of the implication. -
other: The consequent of the implication. -
Returns:
Digit::PoswhenselfisDigit::Neg.- The positive condition of
otherwhenselfisDigit::Zero. otherwhenselfisDigit::Pos.
Implements Kleene ternary implication logic, which includes determining the logical result based on antecedent and consequent.
Sourcepub fn l3_imply(&self, other: Self) -> Self
pub fn l3_imply(&self, other: Self) -> Self
Performs Łukasiewicz implication with the current Digit as self and another Digit.
-
self: The antecedent of the implication. -
other: The consequent of the implication. -
Returns:
Digit::PoswhenselfisDigit::Neg.- The non-negative condition of
otherwhenselfisDigit::Zero. otherwhenselfisDigit::Pos.
Implements Łukasiewicz ternary implication logic, which evaluates an alternative approach for implication compared to Kleene logic.
Sourcepub fn rm3_imply(&self, other: Self) -> Self
pub fn rm3_imply(&self, other: Self) -> Self
Performs RM3 implication with the current Digit as self and another Digit.
-
self: The antecedent of the implication. -
other: The consequent of the implication. -
Returns:
Digit::PoswhenselfisDigit::Neg.otherwhenselfisDigit::Zero.- The necessary condition of
otherwhenselfisDigit::Pos.
Implements RM3 ternary implication logic, which defines a unique perspective for implication operations in balanced ternary systems.
Sourcepub fn ht_imply(&self, other: Self) -> Self
pub fn ht_imply(&self, other: Self) -> Self
Performs HT implication with the current Digit as self and another Digit.
-
self: The antecedent of the implication. -
other: The consequent of the implication. -
Returns:
Digit::PoswhenselfisDigit::Neg.- The possibility condition of
otherwhenselfisDigit::Zero. otherwhenselfisDigit::Pos.
This method computes HT ternary implication based on heuristic logic.