Compare commits
4 changed files with 5 additions and 12 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -7,15 +7,14 @@ use std::{
|
||||||
use tylc as lib;
|
use tylc as lib;
|
||||||
|
|
||||||
fn main() -> ExitCode {
|
fn main() -> ExitCode {
|
||||||
let input = env::args()
|
let input = match env::args().skip(1).rev().reduce(|x, a| a + &x) {
|
||||||
.skip(1)
|
Some(s) => s,
|
||||||
.rev()
|
None => {
|
||||||
.reduce(|x, a| a + &x)
|
|
||||||
.unwrap_or_else(|| {
|
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
io::stdin().read_to_string(&mut buf).unwrap();
|
io::stdin().read_to_string(&mut buf).unwrap();
|
||||||
buf
|
buf
|
||||||
});
|
}
|
||||||
|
};
|
||||||
|
|
||||||
match lib::formatting::pretty_eval(input, 10) {
|
match lib::formatting::pretty_eval(input, 10) {
|
||||||
Ok(s) => println!("{s}"),
|
Ok(s) => println!("{s}"),
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,6 @@ 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(),
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,6 @@ pub enum Operator {
|
||||||
pub enum Function {
|
pub enum Function {
|
||||||
Sqrt,
|
Sqrt,
|
||||||
|
|
||||||
Ln,
|
|
||||||
|
|
||||||
Sine,
|
Sine,
|
||||||
ArcSine,
|
ArcSine,
|
||||||
Cosine,
|
Cosine,
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,6 @@ 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),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue