mirror of https://github.com/rm-dr/daisy
Added ** exponentiation
parent
e5b7aa2d1a
commit
56521cbbcd
|
@ -19,7 +19,6 @@ This is nowhere near complete. Stay tuned.
|
||||||
- Arrows to move cursor
|
- Arrows to move cursor
|
||||||
- Documentation
|
- Documentation
|
||||||
- Branding
|
- Branding
|
||||||
- ** as exponentiation
|
|
||||||
- Improve tests
|
- Improve tests
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -309,13 +309,13 @@ mod tests {
|
||||||
|
|
||||||
good_expr(64f64, "4^3");
|
good_expr(64f64, "4^3");
|
||||||
good_expr(64f64, "4 ^ 3");
|
good_expr(64f64, "4 ^ 3");
|
||||||
//good_expr(64f64, "4**3");
|
good_expr(64f64, "4**3");
|
||||||
//good_expr(64f64, "4 ** 3");
|
good_expr(64f64, "4 ** 3");
|
||||||
|
|
||||||
good_expr(-81f64, "-3^4");
|
good_expr(-81f64, "-3^4");
|
||||||
good_expr(-81f64, "-3 ^ 4");
|
good_expr(-81f64, "-3 ^ 4");
|
||||||
//good_expr(-81f64, "-3**4");
|
good_expr(-81f64, "-3**4");
|
||||||
//good_expr(-81f64, "-3 ** 4");
|
good_expr(-81f64, "-3 ** 4");
|
||||||
good_expr(-81f64, "-(3^4)");
|
good_expr(-81f64, "-(3^4)");
|
||||||
|
|
||||||
//good_expr(f64, "3 ^ (-1.4)");
|
//good_expr(f64, "3 ^ (-1.4)");
|
||||||
|
|
|
@ -234,16 +234,16 @@ impl Operator {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn from_string(s: &str) -> Option<Operator> {
|
pub fn from_string(s: &str) -> Option<Operator> {
|
||||||
match s {
|
match s {
|
||||||
"+" => {Some( Operator::Add )},
|
"+" => {Some( Operator::Add )},
|
||||||
"-" => {Some( Operator::Subtract )},
|
"-" => {Some( Operator::Subtract )},
|
||||||
"neg" => {Some( Operator::Negative )},
|
"neg" => {Some( Operator::Negative )},
|
||||||
"*"|"×" => {Some( Operator::Multiply )},
|
"*"|"×" => {Some( Operator::Multiply )},
|
||||||
"/"|"÷" => {Some( Operator::Divide )},
|
"/"|"÷" => {Some( Operator::Divide )},
|
||||||
"i*" => {Some( Operator::ImplicitMultiply )},
|
"i*" => {Some( Operator::ImplicitMultiply )},
|
||||||
"%" => {Some( Operator::Modulo )},
|
"%" => {Some( Operator::Modulo )},
|
||||||
"mod" => {Some( Operator::ModuloLong )},
|
"mod" => {Some( Operator::ModuloLong )},
|
||||||
"^" => {Some( Operator::Power )},
|
"^"|"**" => {Some( Operator::Power )},
|
||||||
"!" => {Some( Operator::Factorial )},
|
"!" => {Some( Operator::Factorial )},
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue