From: Mark Thom Date: Sun, 21 Feb 2021 01:31:47 +0000 (-0700) Subject: add 'e' as evaluable functor for Euler's constant (#832) X-Git-Tag: v0.9.0~150^2~30 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=eb5ea28bcde8674d6505c7cfe0cdbda0527e3e6a;p=scryer-prolog.git add 'e' as evaluable functor for Euler's constant (#832) --- 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);