diff --git a/src/main.rs b/src/main.rs index c3349d2..dc19a05 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,15 +7,14 @@ use std::{ use tylc as lib; fn main() -> ExitCode { - let input = env::args() - .skip(1) - .rev() - .reduce(|x, a| a + &x) - .unwrap_or_else(|| { + let input = match env::args().skip(1).rev().reduce(|x, a| a + &x) { + Some(s) => s, + None => { let mut buf = String::new(); io::stdin().read_to_string(&mut buf).unwrap(); buf - }); + } + }; match lib::formatting::pretty_eval(input, 10) { Ok(s) => println!("{s}"), diff --git a/src/nodes/eval.rs b/src/nodes/eval.rs index ea06c2b..27d6907 100644 --- a/src/nodes/eval.rs +++ b/src/nodes/eval.rs @@ -52,8 +52,6 @@ fn collapse_toplevel(nodes: &mut Vec, mut end: usize) -> Result<(), Error> Node::Number(n) => match variant { Function::Sqrt => n.sqrt_mut(), - Function::Ln => n.ln_mut(), - Function::Sine => n.sin_mut(), Function::ArcSine => n.asin_mut(), Function::Cosine => n.cos_mut(), diff --git a/src/nodes/mod.rs b/src/nodes/mod.rs index dbc5461..d8e05d9 100644 --- a/src/nodes/mod.rs +++ b/src/nodes/mod.rs @@ -76,8 +76,6 @@ pub enum Operator { pub enum Function { Sqrt, - Ln, - Sine, ArcSine, Cosine, diff --git a/src/nodes/parse.rs b/src/nodes/parse.rs index 50d0f13..4a20221 100644 --- a/src/nodes/parse.rs +++ b/src/nodes/parse.rs @@ -37,8 +37,6 @@ impl FromStr for Function { match s { "sqrt" => Ok(Self::Sqrt), - "ln" => Ok(Self::Ln), - "sin" => Ok(Self::Sine), "asin" => Ok(Self::ArcSine), "cos" => Ok(Self::Cosine),