diff --git a/src/nodes/evaluate.rs b/src/nodes/evaluate.rs index eae3d8e..c9984bd 100644 --- a/src/nodes/evaluate.rs +++ b/src/nodes/evaluate.rs @@ -40,6 +40,8 @@ fn collapse_toplevel(nodes: &mut Vec, mut end: usize) { { match &mut nodes[start..end][index + 1] { Node::Number(n) => match variant { + Function::Sqrt => n.sqrt_mut(), + Function::Sine => n.sin_mut(), Function::ArcSine => n.asin_mut(), Function::Cosine => n.cos_mut(), diff --git a/src/nodes/from_str.rs b/src/nodes/from_str.rs index b2d6535..754e5f2 100644 --- a/src/nodes/from_str.rs +++ b/src/nodes/from_str.rs @@ -32,6 +32,8 @@ impl FromStr for Function { type Err = String; fn from_str(s: &str) -> Result { match s { + "sqrt" => Ok(Self::Sqrt), + "sin" => Ok(Self::Sine), "asin" => Ok(Self::ArcSine), "cos" => Ok(Self::Cosine), diff --git a/src/nodes/mod.rs b/src/nodes/mod.rs index a7326bf..f46ad3b 100644 --- a/src/nodes/mod.rs +++ b/src/nodes/mod.rs @@ -40,6 +40,8 @@ enum Operator { #[derive(Debug, Copy, Clone, PartialEq)] enum Function { + Sqrt, + Sine, ArcSine, Cosine,