some rustfmt updates
This commit is contained in:
parent
0c5d14ed8e
commit
5d89c6b684
3 changed files with 15 additions and 13 deletions
|
|
@ -210,7 +210,7 @@ Will need a concatenate function for tables
|
|||
**** DONE mul
|
||||
**** DONE exp
|
||||
**** DONE mod
|
||||
***** TODO Test for Let Destructuring
|
||||
***** DONE Test for Let Destructuring
|
||||
**** TODO inc
|
||||
**** TODO dec
|
||||
**** TODO gt?
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ fn isnumeric(arg: &Ctr) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
pub const ADD_DOCSTRING: &str = "traverses over N args, which must all evaluate to an Integer or Float.
|
||||
pub const ADD_DOCSTRING: &str =
|
||||
"traverses over N args, which must all evaluate to an Integer or Float.
|
||||
Adds each arg up to a final result. WARNING: does not acocunt for under/overflows.
|
||||
Consult source code for a better understanding of how extreme values will be handled.";
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ Consult source code for a better understanding of how extreme values will be han
|
|||
|
||||
pub fn sub_callback(ast: &Seg, _: &mut SymTable) -> Result<Ctr, String> {
|
||||
if !isnumeric(&*ast.car) {
|
||||
return Err(format!("{} is not a number", &*ast.car))
|
||||
return Err(format!("{} is not a number", &*ast.car));
|
||||
}
|
||||
let mut res = *ast.car.clone();
|
||||
let mut culprit: Ctr = Ctr::None;
|
||||
|
|
@ -80,7 +81,6 @@ pub fn sub_callback(ast: &Seg, _: &mut SymTable) -> Result<Ctr, String> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
pub const DIV_DOCSTRING: &str = "takes two args, which must both evaluate to an Integer or Float.
|
||||
divides arg1 by arg2. WARNING: does not acocunt for under/overflows or float precision.
|
||||
Consult source code for a better understanding of how extreme values will be handled.";
|
||||
|
|
@ -102,7 +102,8 @@ pub fn div_callback(ast: &Seg, _: &mut SymTable) -> Result<Ctr, String> {
|
|||
}
|
||||
}
|
||||
|
||||
pub const MUL_DOCSTRING: &str = "traverses over N args, which must all evaluate to an Integer or Float.
|
||||
pub const MUL_DOCSTRING: &str =
|
||||
"traverses over N args, which must all evaluate to an Integer or Float.
|
||||
Multiplies each arg up to a final result. WARNING: does not acocunt for under/overflows.
|
||||
Consult source code for a better understanding of how extreme values will be handled.";
|
||||
|
||||
|
|
@ -178,7 +179,7 @@ PANIC CASES:
|
|||
- an integer is rased to the power of another integer exceeding the max size of an unsigned 32bit integer";
|
||||
|
||||
pub fn exp_callback(ast: &Seg, _: &mut SymTable) -> Result<Ctr, String> {
|
||||
let first = *ast.car.clone();
|
||||
let first = *ast.car.clone();
|
||||
if !isnumeric(&first) {
|
||||
return Err("first argument must be numeric".to_string());
|
||||
}
|
||||
|
|
@ -218,7 +219,7 @@ PANIC CASES:
|
|||
";
|
||||
|
||||
pub fn mod_callback(ast: &Seg, _: &mut SymTable) -> Result<Ctr, String> {
|
||||
let first = *ast.car.clone();
|
||||
let first = *ast.car.clone();
|
||||
if !isnumeric(&first) {
|
||||
return Err("first argument must be numeric".to_string());
|
||||
}
|
||||
|
|
@ -239,27 +240,27 @@ pub fn mod_callback(ast: &Seg, _: &mut SymTable) -> Result<Ctr, String> {
|
|||
Ctr::Float(rf) => {
|
||||
ret.append(Box::new(Ctr::Integer((lf / rf) as i128)));
|
||||
ret.append(Box::new(Ctr::Integer((lf % rf) as i128)));
|
||||
},
|
||||
}
|
||||
Ctr::Integer(ri) => {
|
||||
ret.append(Box::new(Ctr::Integer((lf / ri as f64) as i128)));
|
||||
ret.append(Box::new(Ctr::Integer((lf % ri as f64) as i128)));
|
||||
},
|
||||
}
|
||||
_ => return Err("mod not implemented for these arguments".to_string()),
|
||||
},
|
||||
Ctr::Integer(li) => match second {
|
||||
Ctr::Float(rf) => {
|
||||
ret.append(Box::new(Ctr::Integer((li as f64 / rf) as i128)));
|
||||
ret.append(Box::new(Ctr::Integer((li as f64 % rf) as i128))); },
|
||||
ret.append(Box::new(Ctr::Integer((li as f64 % rf) as i128)));
|
||||
}
|
||||
Ctr::Integer(ri) => {
|
||||
ret.append(Box::new(Ctr::Integer(li / ri)));
|
||||
ret.append(Box::new(Ctr::Integer(li % ri)));
|
||||
},
|
||||
}
|
||||
_ => return Err("mod not implemented for these arguments".to_string()),
|
||||
},
|
||||
|
||||
_ => return Err("mod not implemented for these arguments".to_string()),
|
||||
}
|
||||
|
||||
|
||||
Ok(Ctr::Seg(ret))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,7 +258,8 @@ mod math_lib_tests {
|
|||
fn test_fi_mod() {
|
||||
let document = "(def test '' (mod 7.2 2))";
|
||||
let check1 = "(car test)";
|
||||
let result1 = "3"; let mut syms = SymTable::new();
|
||||
let result1 = "3";
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms).unwrap();
|
||||
dynamic_stdlib(&mut syms).unwrap();
|
||||
let _ = *eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue