From 25644b9d4ed1bb6a8696eb653b29b1de6896d06a Mon Sep 17 00:00:00 2001 From: Book-reader Date: Fri, 5 Sep 2025 19:39:48 +1200 Subject: [PATCH] Add `get_val` --- asklyphe-frontend/src/math.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/asklyphe-frontend/src/math.rs b/asklyphe-frontend/src/math.rs index 16c3412..fc7b224 100644 --- a/asklyphe-frontend/src/math.rs +++ b/asklyphe-frontend/src/math.rs @@ -81,6 +81,18 @@ enum Atom { Const(Const), } +impl Atom { + fn get_val(&self) -> f64 { + match self { + Atom::Number(val) => *val, + Atom::Const(c) => match c { + Const::Pi => 3.141592653589793238462643383279, + Const::E => 2.718281828459045235360287471352, + } + } + } +} + #[derive(Debug, Copy, Clone)] enum Func { Sine,