feat: add ln function

this one is easier than log or root, because it only takes one arg
This commit is contained in:
electria 2026-10-06 11:51:04 -07:00
commit f1c6073708
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs
3 changed files with 6 additions and 0 deletions

View file

@ -52,6 +52,8 @@ fn collapse_toplevel(nodes: &mut Vec<Node>, mut end: usize) -> Result<(), Error>
Node::Number(n) => match variant { Node::Number(n) => match variant {
Function::Sqrt => n.sqrt_mut(), Function::Sqrt => n.sqrt_mut(),
Function::Ln => n.ln_mut(),
Function::Sine => n.sin_mut(), Function::Sine => n.sin_mut(),
Function::ArcSine => n.asin_mut(), Function::ArcSine => n.asin_mut(),
Function::Cosine => n.cos_mut(), Function::Cosine => n.cos_mut(),

View file

@ -76,6 +76,8 @@ pub enum Operator {
pub enum Function { pub enum Function {
Sqrt, Sqrt,
Ln,
Sine, Sine,
ArcSine, ArcSine,
Cosine, Cosine,

View file

@ -37,6 +37,8 @@ impl FromStr for Function {
match s { match s {
"sqrt" => Ok(Self::Sqrt), "sqrt" => Ok(Self::Sqrt),
"ln" => Ok(Self::Ln),
"sin" => Ok(Self::Sine), "sin" => Ok(Self::Sine),
"asin" => Ok(Self::ArcSine), "asin" => Ok(Self::ArcSine),
"cos" => Ok(Self::Cosine), "cos" => Ok(Self::Cosine),