From eb5ea28bcde8674d6505c7cfe0cdbda0527e3e6a Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Sat, 20 Feb 2021 18:31:47 -0700 Subject: [PATCH] add 'e' as evaluable functor for Euler's constant (#832) --- src/arithmetic.rs | 6 ++++++ src/machine/arithmetic_ops.rs | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/arithmetic.rs b/src/arithmetic.rs index 7941ed3b..bcaf239f 100644 --- a/src/arithmetic.rs +++ b/src/arithmetic.rs @@ -278,6 +278,12 @@ impl<'a> ArithmeticEvaluator<'a> { &Constant::Rational(ref n) => self .interm .push(ArithmeticTerm::Number(Number::Rational(n.clone()))), + &Constant::Atom(ref name, _) if name.as_str() == "e" => { + self.interm + .push(ArithmeticTerm::Number(Number::Float(OrderedFloat( + f64::consts::E, + )))) + } &Constant::Atom(ref name, _) if name.as_str() == "pi" => { self.interm .push(ArithmeticTerm::Number(Number::Float(OrderedFloat( diff --git a/src/machine/arithmetic_ops.rs b/src/machine/arithmetic_ops.rs index 63ec2d6d..9ce4eac0 100644 --- a/src/machine/arithmetic_ops.rs +++ b/src/machine/arithmetic_ops.rs @@ -224,6 +224,9 @@ impl MachineState { &HeapCellValue::Atom(ref name, _) if name.as_str() == "pi" => { interms.push(Number::Float(OrderedFloat(f64::consts::PI))) } + &HeapCellValue::Atom(ref name, _) if name.as_str() == "e" => { + interms.push(Number::Float(OrderedFloat(f64::consts::E))) + } &HeapCellValue::NamedStr(arity, ref name, _) => { let evaluable_stub = MachineError::functor_stub(name.clone(), arity); -- 2.54.0