Compare commits

...

5 Commits

Author SHA1 Message Date
Mark 6e3609d85e
Updated TODO 2023-08-17 17:33:54 -07:00
Mark f9ec4d82fe
Added a test 2023-08-17 17:31:43 -07:00
Mark 86b5356d4f
Updated TODO 2023-08-17 16:38:17 -07:00
Mark cc81c3979c
Fixed mod bug 2023-08-17 16:38:02 -07:00
Mark b846a7c144
Fixed help art 2023-08-17 12:49:29 -07:00
6 changed files with 15 additions and 5 deletions

View File

@ -9,7 +9,6 @@
- Update packages - Update packages
## Pre-release ## Pre-release
- Fix linelocation (consistent, what does an operator's linelocation mean?) - Fix linelocation (consistent, what does an operator's linelocation mean?)
- Tuple operations - Tuple operations
@ -30,6 +29,7 @@
- evaluate straight from command line - evaluate straight from command line
- Auto-push to crates.io - Auto-push to crates.io
- Package for debian - Package for debian
- Faster startup
@ -48,6 +48,7 @@
- Complex numbers - Complex numbers
- acot/acoth functions - acot/acoth functions
- Sums and products with functional arguments - Sums and products with functional arguments
- Add functions: gcd, inverse mod
## Prompt ## Prompt
- Live syntax/output (like firefox js terminal) - Live syntax/output (like firefox js terminal)

View File

@ -162,6 +162,11 @@ pub fn eval_operator(context: &mut Context, g: &Expression) -> Result<Option<Exp
if va.fract() != Quantity::new_rational(0f64).unwrap() { return Err((*la + *lb + *op_loc, DaisyError::BadMath)); } if va.fract() != Quantity::new_rational(0f64).unwrap() { return Err((*la + *lb + *op_loc, DaisyError::BadMath)); }
if vb.fract() != Quantity::new_rational(0f64).unwrap() { return Err((*la + *lb + *op_loc, DaisyError::BadMath)); } if vb.fract() != Quantity::new_rational(0f64).unwrap() { return Err((*la + *lb + *op_loc, DaisyError::BadMath)); }
let o = va.clone() % vb.clone();
if o.is_nan() {return Err((*la + *lb + *op_loc, DaisyError::BadMath));}
return Ok(Some(Expression::Quantity(*la + *lb + *op_loc, va.clone() % vb.clone()))); return Ok(Some(Expression::Quantity(*la + *lb + *op_loc, va.clone() % vb.clone())));
} else { return Ok(None); } } else { return Ok(None); }
} else { return Ok(None); } } else { return Ok(None); }

View File

@ -61,10 +61,12 @@ fn format_map_ansi(c: char) -> Option<String> {
} }
// style::reset also resets color.
// Make sure color comes AFTER style reset.
fn format_map_full(c: char) -> Option<String> { fn format_map_full(c: char) -> Option<String> {
Some(match c { Some(match c {
'n' => { // Normal text 'n' => { // Normal text
format!("{}{}", color::Fg(color::Reset), style::Reset) format!("{}{}", style::Reset, color::Fg(color::Reset))
}, },
'i' => { // Normal italic text 'i' => { // Normal italic text
format!("{}{}", color::Fg(color::Reset), style::Italic) format!("{}{}", color::Fg(color::Reset), style::Italic)
@ -73,7 +75,7 @@ fn format_map_full(c: char) -> Option<String> {
format!("{}{}", color::Fg(color::Magenta), style::Bold) format!("{}{}", color::Fg(color::Magenta), style::Bold)
}, },
'a' => { // Colored text 'a' => { // Colored text
format!("{}{}", color::Fg(color::Magenta), style::Reset) format!("{}{}", style::Reset, color::Fg(color::Magenta))
}, },
'e' => { // Error titles 'e' => { // Error titles
format!("{}{}", color::Fg(color::Red), style::Bold) format!("{}{}", color::Fg(color::Red), style::Bold)

View File

@ -244,7 +244,7 @@ impl Rem<FloatBase> for FloatBase {
(!modulus.fract().unwrap().is_zero()) (!modulus.fract().unwrap().is_zero())
} { panic!() } } { panic!() }
FloatBase{val : self.val.fract() % modulus.val.fract()} FloatBase{val : self.val.trunc() % modulus.val.trunc()}
} }
} }

View File

@ -186,7 +186,7 @@ impl Scalar {
pub fn is_nan(&self) -> bool { pub fn is_nan(&self) -> bool {
match self { match self {
Scalar::Float {v} => {v.val.is_nan()}, Scalar::Float {v} => {v.val.is_nan()},
Scalar::Rational {..} => {panic!()} Scalar::Rational {..} => {false}
} }
} }

View File

@ -162,6 +162,7 @@ fn operators() {
good_expr("2", "6/3"); good_expr("2", "6/3");
good_expr("2", "5%3"); good_expr("2", "5%3");
good_expr("4", "2^5 mod 7");
good_expr("8", "5+3"); good_expr("8", "5+3");
good_expr("64", "4^3"); good_expr("64", "4^3");
good_expr("64", "4 ^ 3"); good_expr("64", "4 ^ 3");
@ -184,6 +185,7 @@ fn operators() {
bad_expr("1e5!"); bad_expr("1e5!");
bad_expr("0^(-1)"); bad_expr("0^(-1)");
bad_expr("pi!"); bad_expr("pi!");
bad_expr("2.5 mod 8");
} }
#[test] #[test]