Enum Digit

Source
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§

§

Neg

Represents -1

§

Zero

Represents 0

§

Pos

Represents +1

Implementations§

Source§

impl Digit

Source

pub fn to_char(&self) -> char

Converts the Digit into its character representation.

  • Returns:
    • - for Digit::Neg
    • 0 for Digit::Zero
    • + for Digit::Pos
Source

pub fn from_char(c: char) -> Digit

Creates a Digit from its character representation.

  • Accepts:
    • - for Digit::Neg
    • 0 for Digit::Zero
    • + for Digit::Pos
  • Panics if the input character is invalid.
Source

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
Source

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
  • Panics if the input integer is invalid.
Source

pub fn possibly(&self) -> Self

Returns the corresponding possible value of the current Digit.

  • Returns:
    • Digit::Neg for Digit::Neg
    • Digit::Pos for Digit::Zero
    • Digit::Pos for Digit::Pos
Source

pub fn necessary(&self) -> Self

Determines the condition of necessity for the current Digit.

  • Returns:
    • Digit::Neg for Digit::Neg
    • Digit::Neg for Digit::Zero
    • Digit::Pos for Digit::Pos

This method is used to calculate necessity as part of balanced ternary logic systems.

Source

pub fn contingently(&self) -> Self

Determines the condition of contingency for the current Digit.

  • Returns:
    • Digit::Neg for Digit::Neg
    • Digit::Pos for Digit::Zero
    • Digit::Neg for Digit::Pos

This method represents contingency in balanced ternary logic, which defines the specific alternation of Digit values.

Source

pub fn not_negative(&self) -> Self

Determines the condition of non-negativity for the current Digit.

  • Returns:
    • Digit::Zero for Digit::Neg
    • Digit::Pos for Digit::Zero
    • Digit::Pos for Digit::Pos

This method is used to filter out negative conditions in computations with balanced ternary representations.

Source

pub fn positive(&self) -> Self

Determines the strictly positive condition for the current Digit.

  • Returns:
    • Digit::Zero for Digit::Neg
    • Digit::Zero for Digit::Zero
    • Digit::Pos for Digit::Pos

This method is used to calculate strictly positive states in association with ternary logic.

Source

pub fn not_positive(&self) -> Self

Determines the condition of non-positivity for the current Digit.

  • Returns:
    • Digit::Pos for Digit::Neg
    • Digit::Pos for Digit::Zero
    • Digit::Zero for Digit::Pos

This method complements the positive condition and captures states that are not strictly positive.

Source

pub fn negative(&self) -> Self

Determines the strictly negative condition for the current Digit.

  • Returns:
    • Digit::Pos for Digit::Neg
    • Digit::Zero for Digit::Zero
    • Digit::Zero for Digit::Pos

This method calculates strictly negative states in association with ternary logic.

Source

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::Pos when self is Digit::Neg.
    • The positive condition of other when self is Digit::Zero.
    • other when self is Digit::Pos.

Implements Kleene ternary implication logic, which includes determining the logical result based on antecedent and consequent.

Source

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::Pos when self is Digit::Neg.
    • The non-negative condition of other when self is Digit::Zero.
    • other when self is Digit::Pos.

Implements Łukasiewicz ternary implication logic, which evaluates an alternative approach for implication compared to Kleene logic.

Source

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::Pos when self is Digit::Neg.
    • other when self is Digit::Zero.
    • The necessary condition of other when self is Digit::Pos.

Implements RM3 ternary implication logic, which defines a unique perspective for implication operations in balanced ternary systems.

Source

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::Pos when self is Digit::Neg.
    • The possibility condition of other when self is Digit::Zero.
    • other when self is Digit::Pos.

This method computes HT ternary implication based on heuristic logic.

Source

pub fn ht_not(&self) -> Self

Performs HT logical negation of the current Digit.

  • Returns:
    • Digit::Pos when self is Digit::Neg.
    • Digit::Neg when self is Digit::Zero or Digit::Pos.

This method evaluates the HT negation result using heuristic ternary logic.

Trait Implementations§

Source§

impl Add for Digit

Source§

type Output = Ternary

The resulting type after applying the + operator.
Source§

fn add(self, other: Digit) -> Self::Output

Performs the + operation. Read more
Source§

impl BitAnd for Digit

Source§

type Output = Digit

The resulting type after applying the & operator.
Source§

fn bitand(self, other: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitOr for Digit

Source§

type Output = Digit

The resulting type after applying the | operator.
Source§

fn bitor(self, other: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl BitXor for Digit

Source§

type Output = Digit

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl Clone for Digit

Source§

fn clone(&self) -> Digit

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Digit

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Div for Digit

Source§

type Output = Digit

The resulting type after applying the / operator.
Source§

fn div(self, other: Digit) -> Self::Output

Performs the / operation. Read more
Source§

impl Hash for Digit

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Mul for Digit

Source§

type Output = Digit

The resulting type after applying the * operator.
Source§

fn mul(self, other: Digit) -> Self::Output

Performs the * operation. Read more
Source§

impl Neg for Digit

Source§

fn neg(self) -> Self::Output

Returns the negation of the Digit.

  • Digit::Neg becomes Digit::Pos
  • Digit::Pos becomes Digit::Neg
  • Digit::Zero remains Digit::Zero
Source§

type Output = Digit

The resulting type after applying the - operator.
Source§

impl Not for Digit

Source§

type Output = Digit

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl PartialEq for Digit

Source§

fn eq(&self, other: &Digit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sub for Digit

Source§

type Output = Ternary

The resulting type after applying the - operator.
Source§

fn sub(self, other: Digit) -> Self::Output

Performs the - operation. Read more
Source§

impl Copy for Digit

Source§

impl Eq for Digit

Source§

impl StructuralPartialEq for Digit

Auto Trait Implementations§

§

impl Freeze for Digit

§

impl RefUnwindSafe for Digit

§

impl Send for Digit

§

impl Sync for Digit

§

impl Unpin for Digit

§

impl UnwindSafe for Digit

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.