mirror of
				https://github.com/rm-dr/daisy
				synced 2025-11-04 04:31:50 -08:00 
			
		
		
		
	Compare commits
	
		
			5 Commits
		
	
	
		
			09996801d8
			...
			6e3609d85e
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						6e3609d85e
	
				 | 
					
					
						|||
| 
						
						
							
						
						f9ec4d82fe
	
				 | 
					
					
						|||
| 
						
						
							
						
						86b5356d4f
	
				 | 
					
					
						|||
| 
						
						
							
						
						cc81c3979c
	
				 | 
					
					
						|||
| 
						
						
							
						
						b846a7c144
	
				 | 
					
					
						
							
								
								
									
										3
									
								
								TODO.md
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								TODO.md
									
									
									
									
									
								
							@@ -9,7 +9,6 @@
 | 
			
		||||
 - Update packages
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Pre-release
 | 
			
		||||
 - Fix linelocation (consistent, what does an operator's linelocation mean?)
 | 
			
		||||
 - Tuple operations
 | 
			
		||||
@@ -30,6 +29,7 @@
 | 
			
		||||
 - evaluate straight from command line
 | 
			
		||||
 - Auto-push to crates.io
 | 
			
		||||
 - Package for debian
 | 
			
		||||
 - Faster startup
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -48,6 +48,7 @@
 | 
			
		||||
 - Complex numbers
 | 
			
		||||
 - acot/acoth functions
 | 
			
		||||
 - Sums and products with functional arguments
 | 
			
		||||
 - Add functions: gcd, inverse mod
 | 
			
		||||
 | 
			
		||||
## Prompt
 | 
			
		||||
 - Live syntax/output (like firefox js terminal)
 | 
			
		||||
 
 | 
			
		||||
@@ -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 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())));
 | 
			
		||||
				} else { return Ok(None); }
 | 
			
		||||
			} else { return Ok(None); }
 | 
			
		||||
 
 | 
			
		||||
@@ -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> {
 | 
			
		||||
	Some(match c {
 | 
			
		||||
		'n' => { // Normal text
 | 
			
		||||
			format!("{}{}", color::Fg(color::Reset), style::Reset)
 | 
			
		||||
			format!("{}{}", style::Reset, color::Fg(color::Reset))
 | 
			
		||||
		},
 | 
			
		||||
		'i' => { // Normal italic text
 | 
			
		||||
			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)
 | 
			
		||||
		},
 | 
			
		||||
		'a' => { // Colored text
 | 
			
		||||
			format!("{}{}", color::Fg(color::Magenta), style::Reset)
 | 
			
		||||
			format!("{}{}", style::Reset, color::Fg(color::Magenta))
 | 
			
		||||
		},
 | 
			
		||||
		'e' => { // Error titles
 | 
			
		||||
			format!("{}{}", color::Fg(color::Red), style::Bold)
 | 
			
		||||
 
 | 
			
		||||
@@ -244,7 +244,7 @@ impl Rem<FloatBase> for FloatBase {
 | 
			
		||||
			(!modulus.fract().unwrap().is_zero())
 | 
			
		||||
		} { panic!() }
 | 
			
		||||
 | 
			
		||||
		FloatBase{val : self.val.fract() % modulus.val.fract()}
 | 
			
		||||
		FloatBase{val : self.val.trunc() % modulus.val.trunc()}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -186,7 +186,7 @@ impl Scalar {
 | 
			
		||||
	pub fn is_nan(&self) -> bool {
 | 
			
		||||
		match self {
 | 
			
		||||
			Scalar::Float {v} => {v.val.is_nan()},
 | 
			
		||||
			Scalar::Rational {..} => {panic!()}
 | 
			
		||||
			Scalar::Rational {..} => {false}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -162,6 +162,7 @@ fn operators() {
 | 
			
		||||
 | 
			
		||||
	good_expr("2", "6/3");
 | 
			
		||||
	good_expr("2", "5%3");
 | 
			
		||||
	good_expr("4", "2^5 mod 7");
 | 
			
		||||
	good_expr("8", "5+3");
 | 
			
		||||
	good_expr("64", "4^3");
 | 
			
		||||
	good_expr("64", "4 ^ 3");
 | 
			
		||||
@@ -184,6 +185,7 @@ fn operators() {
 | 
			
		||||
	bad_expr("1e5!");
 | 
			
		||||
	bad_expr("0^(-1)");
 | 
			
		||||
	bad_expr("pi!");
 | 
			
		||||
	bad_expr("2.5 mod 8");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[test]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user