pull/2/head
Mark 2023-03-24 13:18:56 -07:00
parent 1f9bcccab4
commit 1f98645dd4
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
2 changed files with 9 additions and 27 deletions

View File

@ -152,24 +152,7 @@ impl Eval for Token {
} else { panic!(); }
},
Token::Root(ref v) => {
if v.len() != 2 {panic!()};
let a = &v[0];
let b = &v[1];
if let Token::Number(la, va) = a {
if let Token::Number(lb, vb) = b {
let LineLocation{pos: posa, ..} = *la;
let LineLocation{pos: posb, len: lenb} = lb;
Token::Number(
LineLocation { pos: posa, len: posb - posa + lenb },
va.powf(1f64 / *vb)
)
} else { panic!(); }
} else { panic!(); }
},
Token::Factorial(ref v) => { todo!() },
Token::Factorial(ref _v) => { todo!() },
_ => panic!()
}
}

View File

@ -1,10 +1,9 @@
use std::collections::VecDeque;
use crate::parser::Token;
use crate::parser::Eval;
use crate::parser::LineLocation;
use crate::parser::ParserError;
#[inline(always)]
fn get_at_coords<'a>(g: &'a mut Token, coords: &Vec<usize>) -> &'a mut Token {
let mut h = &mut *g;
@ -69,13 +68,13 @@ pub fn evaluate(
}
match h {
Token::Multiply(v) |
Token::Divide(v) |
Token::Add(v) |
Token::Factorial(v) |
Token::Negative(v) |
Token::Power(v) |
Token::Modulo(v)
Token::Multiply(_) |
Token::Divide(_) |
Token::Add(_) |
Token::Factorial(_) |
Token::Negative(_) |
Token::Power(_) |
Token::Modulo(_)
=> {
coords.push(0);
continue 'outer;