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 mul
|
||||||
**** DONE exp
|
**** DONE exp
|
||||||
**** DONE mod
|
**** DONE mod
|
||||||
***** TODO Test for Let Destructuring
|
***** DONE Test for Let Destructuring
|
||||||
**** TODO inc
|
**** TODO inc
|
||||||
**** TODO dec
|
**** TODO dec
|
||||||
**** TODO gt?
|
**** 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.
|
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.";
|
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> {
|
pub fn sub_callback(ast: &Seg, _: &mut SymTable) -> Result<Ctr, String> {
|
||||||
if !isnumeric(&*ast.car) {
|
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 res = *ast.car.clone();
|
||||||
let mut culprit: Ctr = Ctr::None;
|
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.
|
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.
|
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.";
|
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.
|
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.";
|
Consult source code for a better understanding of how extreme values will be handled.";
|
||||||
|
|
||||||
|
|
@ -239,27 +240,27 @@ pub fn mod_callback(ast: &Seg, _: &mut SymTable) -> Result<Ctr, String> {
|
||||||
Ctr::Float(rf) => {
|
Ctr::Float(rf) => {
|
||||||
ret.append(Box::new(Ctr::Integer((lf / rf) as i128)));
|
ret.append(Box::new(Ctr::Integer((lf / rf) as i128)));
|
||||||
ret.append(Box::new(Ctr::Integer((lf % rf) as i128)));
|
ret.append(Box::new(Ctr::Integer((lf % rf) as i128)));
|
||||||
},
|
}
|
||||||
Ctr::Integer(ri) => {
|
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)));
|
||||||
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()),
|
_ => return Err("mod not implemented for these arguments".to_string()),
|
||||||
},
|
},
|
||||||
Ctr::Integer(li) => match second {
|
Ctr::Integer(li) => match second {
|
||||||
Ctr::Float(rf) => {
|
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))); },
|
ret.append(Box::new(Ctr::Integer((li as f64 % rf) as i128)));
|
||||||
|
}
|
||||||
Ctr::Integer(ri) => {
|
Ctr::Integer(ri) => {
|
||||||
ret.append(Box::new(Ctr::Integer(li / ri)));
|
ret.append(Box::new(Ctr::Integer(li / 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()),
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => return Err("mod not implemented for these arguments".to_string()),
|
_ => return Err("mod not implemented for these arguments".to_string()),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Ok(Ctr::Seg(ret))
|
Ok(Ctr::Seg(ret))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,8 @@ mod math_lib_tests {
|
||||||
fn test_fi_mod() {
|
fn test_fi_mod() {
|
||||||
let document = "(def test '' (mod 7.2 2))";
|
let document = "(def test '' (mod 7.2 2))";
|
||||||
let check1 = "(car test)";
|
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();
|
static_stdlib(&mut syms).unwrap();
|
||||||
dynamic_stdlib(&mut syms).unwrap();
|
dynamic_stdlib(&mut syms).unwrap();
|
||||||
let _ = *eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();
|
let _ = *eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue