pub enum LogosValue {
Show 18 variants
Int(i64),
BigInt(Arc<BigInt>),
Rational(Arc<Rational>),
Float(f64),
Decimal(Arc<Decimal>),
Bool(bool),
Text(Arc<str>),
Nothing,
List(Arc<Vec<LogosValue>>),
Tuple(Arc<Vec<LogosValue>>),
Algebraic(Arc<Algebraic>),
ExactReal(Arc<ExactReal>),
Hyperreal(Arc<HyperValue>),
Hypernatural(Arc<NaturalValue>),
Ordinal(Arc<Ordinal>),
Depends(Arc<DependsValue<LogosValue>>),
Converging(Arc<Converging<LogosValue>>),
Other(Arc<dyn OtherValue>),
}Expand description
A value of a compiled program where the exact extension reaches. See the module documentation.
Variants§
Int(i64)
BigInt(Arc<BigInt>)
An integer outside i64; never one that fits.
Rational(Arc<Rational>)
A rational that is not whole.
Float(f64)
Decimal(Arc<Decimal>)
Bool(bool)
Text(Arc<str>)
Nothing
List(Arc<Vec<LogosValue>>)
Tuple(Arc<Vec<LogosValue>>)
Algebraic(Arc<Algebraic>)
ExactReal(Arc<ExactReal>)
Hyperreal(Arc<HyperValue>)
Hypernatural(Arc<NaturalValue>)
Ordinal(Arc<Ordinal>)
Depends(Arc<DependsValue<LogosValue>>)
Converging(Arc<Converging<LogosValue>>)
Other(Arc<dyn OtherValue>)
A value of a kind the exact types do not mix with — a date, a span of time, a moment — held as its own compiled value, which prints, compares and combines as the interpreter’s does.
Implementations§
Source§impl LogosValue
impl LogosValue
Sourcepub fn from_bigint(b: BigInt) -> LogosValue
pub fn from_bigint(b: BigInt) -> LogosValue
An integer in its smallest form.
Sourcepub fn from_rational(r: Rational) -> LogosValue
pub fn from_rational(r: Rational) -> LogosValue
A rational in its smallest form: an integer when it is whole.
Sourcepub fn text(t: &str) -> LogosValue
pub fn text(t: &str) -> LogosValue
Text.
Sourcepub fn list(items: Vec<LogosValue>) -> LogosValue
pub fn list(items: Vec<LogosValue>) -> LogosValue
A list.
Sourcepub fn other(v: impl OtherValue) -> LogosValue
pub fn other(v: impl OtherValue) -> LogosValue
A value of a kind outside the exact tower.
Sourcepub fn other_as<T: OtherValue>(&self) -> Option<&T>
pub fn other_as<T: OtherValue>(&self) -> Option<&T>
The compiled value of a kind outside the tower this holds, when it holds one of that kind.
Sourcepub fn infinitesimal(
name: &str,
modulus: i64,
allowed: &[i64],
) -> Result<LogosValue, String>
pub fn infinitesimal( name: &str, modulus: i64, allowed: &[i64], ) -> Result<LogosValue, String>
The program’s infinitesimal named name, its reciprocal’s residues modulo modulus limited
to allowed.
Sourcepub fn display_string(&self) -> String
pub fn display_string(&self) -> String
How the value prints.
Sourcepub fn decided_truth(&self) -> Result<bool, String>
pub fn decided_truth(&self) -> Result<bool, String>
The truth a condition reads: a residue-dependent answer, or a provisional one no proof settled, is refused with the sentence every tier gives.
Sourcepub fn add(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn add(&self, o: &LogosValue) -> Result<LogosValue, String>
a + b.
Sourcepub fn sub(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn sub(&self, o: &LogosValue) -> Result<LogosValue, String>
a − b.
Sourcepub fn mul(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn mul(&self, o: &LogosValue) -> Result<LogosValue, String>
a × b.
Sourcepub fn div(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn div(&self, o: &LogosValue) -> Result<LogosValue, String>
The polymorphic /: two integers truncate, a rational divides exactly, a float divides as a
float, the exact types divide in their field.
Sourcepub fn exact_div(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn exact_div(&self, o: &LogosValue) -> Result<LogosValue, String>
/ in an exact context: every integer and rational divides exactly; a float defers to /.
Sourcepub fn floor_div(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn floor_div(&self, o: &LogosValue) -> Result<LogosValue, String>
Floor division.
Sourcepub fn rem(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn rem(&self, o: &LogosValue) -> Result<LogosValue, String>
The remainder of two integers, its sign the dividend’s.
Sourcepub fn pow(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn pow(&self, o: &LogosValue) -> Result<LogosValue, String>
base ^ exponent.
Sourcepub fn relation(&self, rel: Rel, o: &LogosValue) -> Result<LogosValue, String>
pub fn relation(&self, rel: Rel, o: &LogosValue) -> Result<LogosValue, String>
a rel b: a Bool, or a residue-dependent one where the answer depends on ⌈1/dt⌉.
Sourcepub fn values_equal(&self, o: &LogosValue) -> bool
pub fn values_equal(&self, o: &LogosValue) -> bool
The language’s equality: exact across numeric types, structural on lists and tuples.
Sourcepub fn not(&self) -> Result<LogosValue, String>
pub fn not(&self) -> Result<LogosValue, String>
not v, lifted over residue branches and through provisional values.
Sourcepub fn bit_and(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn bit_and(&self, o: &LogosValue) -> Result<LogosValue, String>
a & b: bitwise on integers, logical on booleans, and a non-negative big integer under a low
mask 2^k - 1 leaves its low k bits.
Sourcepub fn bit_or(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn bit_or(&self, o: &LogosValue) -> Result<LogosValue, String>
a | b.
Sourcepub fn bit_xor(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn bit_xor(&self, o: &LogosValue) -> Result<LogosValue, String>
a ^ b.
Sourcepub fn shl(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn shl(&self, o: &LogosValue) -> Result<LogosValue, String>
a << b, the count taken modulo the width.
Sourcepub fn shr(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn shr(&self, o: &LogosValue) -> Result<LogosValue, String>
a >> b, the count taken modulo the width.
Sourcepub fn approx_eq(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn approx_eq(&self, o: &LogosValue) -> Result<LogosValue, String>
a is approximately b, on the two values as floats.
Sourcepub fn seq_concat(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn seq_concat(&self, o: &LogosValue) -> Result<LogosValue, String>
a followed by b: the items of two sequences, in order.
Sourcepub fn abs(&self) -> Result<LogosValue, String>
pub fn abs(&self) -> Result<LogosValue, String>
The builtin abs: exact on integers (promoting |i64::MIN|), rationals and decimals.
Sourcepub fn sqrt(&self) -> Result<LogosValue, String>
pub fn sqrt(&self) -> Result<LogosValue, String>
The builtin sqrt, a float.
Sourcepub fn min(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn min(&self, o: &LogosValue) -> Result<LogosValue, String>
The builtin min.
Sourcepub fn max(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn max(&self, o: &LogosValue) -> Result<LogosValue, String>
The builtin max.
Sourcepub fn power(&self, o: &LogosValue) -> Result<LogosValue, String>
pub fn power(&self, o: &LogosValue) -> Result<LogosValue, String>
The builtin pow: an integer power is exact, a negative one a float.
Sourcepub fn length_of(&self) -> Result<i64, String>
pub fn length_of(&self) -> Result<i64, String>
length of self: a list’s or a tuple’s item count, a text’s byte count.
Sourcepub fn contains_value(&self, value: &LogosValue) -> Result<bool, String>
pub fn contains_value(&self, value: &LogosValue) -> Result<bool, String>
self contains value: an equal item of a list, a substring of a text.
Sourcepub fn items(&self) -> Result<Vec<LogosValue>, String>
pub fn items(&self) -> Result<Vec<LogosValue>, String>
The values a Repeat over self binds, taken once before the loop runs: a list’s items, a
text’s characters.
Sourcepub fn push_value(&mut self, value: LogosValue) -> Result<(), String>
pub fn push_value(&mut self, value: LogosValue) -> Result<(), String>
Push value to self.
Sourcepub fn set_item(
&mut self,
index: &LogosValue,
value: LogosValue,
) -> Result<(), String>
pub fn set_item( &mut self, index: &LogosValue, value: LogosValue, ) -> Result<(), String>
Set item index of self to value.
Sourcepub fn pop_value(&mut self) -> Result<LogosValue, String>
pub fn pop_value(&mut self) -> Result<LogosValue, String>
Pop from self: the last item, or nothing from an empty list.
Sourcepub fn item(&self, index: &LogosValue) -> Result<LogosValue, String>
pub fn item(&self, index: &LogosValue) -> Result<LogosValue, String>
item index of self: the 1-based item of a list or a tuple, the character of a text.
Sourcepub fn slice(
&self,
start: &LogosValue,
end: &LogosValue,
) -> Result<LogosValue, String>
pub fn slice( &self, start: &LogosValue, end: &LogosValue, ) -> Result<LogosValue, String>
items start through end of self: the 1-based, inclusive run of a list’s items (crate::logos_slice_range);
one that reaches outside the list is empty.
Sourcepub fn integer_at(&self, past_word: &str, fraction: &str) -> Result<i64, String>
pub fn integer_at(&self, past_word: &str, fraction: &str) -> Result<i64, String>
The machine integer this is where the language takes one: refused with past_word for an integer past
i64, with fraction for a rational that is not whole, and by its type for any other value.
Sourcepub fn floor(&self) -> Result<LogosValue, String>
pub fn floor(&self) -> Result<LogosValue, String>
The language’s floor.
Sourcepub fn ceil(&self) -> Result<LogosValue, String>
pub fn ceil(&self) -> Result<LogosValue, String>
The language’s ceil.
Sourcepub fn round(&self) -> Result<LogosValue, String>
pub fn round(&self) -> Result<LogosValue, String>
The language’s round.
Source§impl LogosValue
impl LogosValue
Sourcepub fn defined_real(
kind: &str,
base: i64,
name: &str,
f: impl Fn(i64) -> LogosValue + Send + Sync + 'static,
) -> LogosValue
pub fn defined_real( kind: &str, base: i64, name: &str, f: impl Fn(i64) -> LogosValue + Send + Sync + 'static, ) -> LogosValue
The real number f defines by its digits in base or its approximations (kind, as
logicaffeine_base::exact_real::Definition::named reads it), name being how the program
spells f.
Sourcepub fn define_real(
kind: &str,
base: i64,
name: &str,
f: impl Fn(i64) -> Result<LogosValue, String> + Send + Sync + 'static,
) -> Result<LogosValue, String>
pub fn define_real( kind: &str, base: i64, name: &str, f: impl Fn(i64) -> Result<LogosValue, String> + Send + Sync + 'static, ) -> Result<LogosValue, String>
LogosValue::defined_real for a function that may refuse an answer, refused itself when
kind and base name no definition.
Trait Implementations§
Source§impl Clone for LogosValue
impl Clone for LogosValue
Source§fn clone(&self) -> LogosValue
fn clone(&self) -> LogosValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LogosValue
impl Debug for LogosValue
Source§impl Default for LogosValue
An unset slot of an exact type, as the interpreter starts one: nothing.
impl Default for LogosValue
An unset slot of an exact type, as the interpreter starts one: nothing.
Source§impl Display for LogosValue
impl Display for LogosValue
Source§impl From<&str> for LogosValue
impl From<&str> for LogosValue
Source§impl From<()> for LogosValue
impl From<()> for LogosValue
Source§impl From<LogosDate> for LogosValue
impl From<LogosDate> for LogosValue
Source§impl From<LogosDecimal> for LogosValue
impl From<LogosDecimal> for LogosValue
Source§fn from(d: LogosDecimal) -> Self
fn from(d: LogosDecimal) -> Self
Source§impl From<LogosInt> for LogosValue
impl From<LogosInt> for LogosValue
Source§impl From<LogosMoment> for LogosValue
impl From<LogosMoment> for LogosValue
Source§fn from(m: LogosMoment) -> Self
fn from(m: LogosMoment) -> Self
Source§impl From<LogosRational> for LogosValue
impl From<LogosRational> for LogosValue
Source§fn from(r: LogosRational) -> Self
fn from(r: LogosRational) -> Self
Source§impl<T: Clone + Into<LogosValue>> From<LogosSeq<T>> for LogosValue
impl<T: Clone + Into<LogosValue>> From<LogosSeq<T>> for LogosValue
Source§impl From<LogosSpan> for LogosValue
impl From<LogosSpan> for LogosValue
Source§impl From<LogosTime> for LogosValue
impl From<LogosTime> for LogosValue
Source§impl From<String> for LogosValue
impl From<String> for LogosValue
Source§impl<T: Into<LogosValue>> From<Vec<T>> for LogosValue
impl<T: Into<LogosValue>> From<Vec<T>> for LogosValue
Source§impl From<bool> for LogosValue
impl From<bool> for LogosValue
Source§impl From<f64> for LogosValue
impl From<f64> for LogosValue
Source§impl From<i128> for LogosValue
impl From<i128> for LogosValue
Source§impl From<i16> for LogosValue
impl From<i16> for LogosValue
Source§impl From<i32> for LogosValue
impl From<i32> for LogosValue
Source§impl From<i64> for LogosValue
impl From<i64> for LogosValue
Source§impl From<i8> for LogosValue
impl From<i8> for LogosValue
Source§impl From<u128> for LogosValue
impl From<u128> for LogosValue
Source§impl From<u16> for LogosValue
impl From<u16> for LogosValue
Source§impl From<u32> for LogosValue
impl From<u32> for LogosValue
Source§impl From<u64> for LogosValue
impl From<u64> for LogosValue
Source§impl From<u8> for LogosValue
impl From<u8> for LogosValue
Source§impl From<usize> for LogosValue
impl From<usize> for LogosValue
Source§impl LogosIndex<LogosValue> for LogosValue
impl LogosIndex<LogosValue> for LogosValue
Source§type Output = LogosValue
type Output = LogosValue
Source§fn logos_get(&self, index: LogosValue) -> LogosValue
fn logos_get(&self, index: LogosValue) -> LogosValue
Source§impl LogosIndex<i64> for LogosValue
impl LogosIndex<i64> for LogosValue
Source§type Output = LogosValue
type Output = LogosValue
Source§fn logos_get(&self, index: i64) -> LogosValue
fn logos_get(&self, index: i64) -> LogosValue
Source§impl PartialEq for LogosValue
impl PartialEq for LogosValue
Source§impl TowerValue for LogosValue
impl TowerValue for LogosValue
Source§fn exact(&self) -> Option<ExactRef<'_, Self>>
fn exact(&self) -> Option<ExactRef<'_, Self>>
None for any other value.Source§fn standard_rational(&self) -> Option<Rational>
fn standard_rational(&self) -> Option<Rational>
Source§fn exact_rational(&self) -> Option<Rational>
fn exact_rational(&self) -> Option<Rational>
Source§fn is_standard_number(&self) -> bool
fn is_standard_number(&self) -> bool
Source§fn display_string(&self) -> String
fn display_string(&self) -> String
Source§fn values_equal(&self, other: &Self) -> bool
fn values_equal(&self, other: &Self) -> bool
Source§fn is_nothing(&self) -> bool
fn is_nothing(&self) -> bool
nothing.Source§fn from_rational(r: Rational) -> Self
fn from_rational(r: Rational) -> Self
Int when it fits, a big integer, else a rational.Source§fn from_bigint(b: BigInt) -> Self
fn from_bigint(b: BigInt) -> Self
fn boolean(b: bool) -> Self
fn nothing() -> Self
fn algebraic(a: Algebraic) -> Self
fn exact_real(x: ExactReal) -> Self
fn hyper(h: HyperValue) -> Self
fn natural(n: NaturalValue) -> Self
fn ordinal(o: Ordinal) -> Self
fn depends(d: DependsValue<Self>) -> Self
fn converging(c: Converging<Self>) -> Self
Source§impl ValueAlgebra for LogosValue
impl ValueAlgebra for LogosValue
fn add(a: Self, b: Self) -> Result<Self, String>
fn subtract(a: Self, b: Self) -> Result<Self, String>
fn multiply(a: Self, b: Self) -> Result<Self, String>
Source§fn exact_divide(a: Self, b: Self) -> Result<Self, String>
fn exact_divide(a: Self, b: Self) -> Result<Self, String>
/ in an exact context: field division, integers included.Source§fn holds(rel: Rel, a: &Self, b: &Self) -> Result<bool, String>
fn holds(rel: Rel, a: &Self, b: &Self) -> Result<bool, String>
a rel b holds, decided: an answer that depends on the residue, or a provisional
one, is the refusal of the branch.