Fully fledged lambdas, along with efficiency tweaks across the ast
This commit is contained in:
parent
b0bd369c1d
commit
8efa1dbaad
10 changed files with 264 additions and 70 deletions
|
|
@ -127,7 +127,6 @@ Integers and Floats will cast to true if they are 0 and false otherwise.";
|
|||
pub fn boolcast_callback(ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
match &*ast.car {
|
||||
Ctr::Bool(_) => Ok(*ast.car.clone()),
|
||||
Ctr::Symbol(_) => Err("not clear how to cast a symbol to a bool".to_string()),
|
||||
Ctr::String(s) => {
|
||||
if s == "true" {
|
||||
Ok(Ctr::Bool(true))
|
||||
|
|
@ -139,7 +138,7 @@ pub fn boolcast_callback(ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String>
|
|||
},
|
||||
Ctr::Integer(i) => Ok(Ctr::Bool(*i == 0)),
|
||||
Ctr::Float(f) => Ok(Ctr::Bool(*f == 0.0)),
|
||||
Ctr::Seg(_) => Err("cannot convert list to a boolean".to_string()),
|
||||
Ctr::None => Err("Impossible task: cannot convert none to bool".to_string()),
|
||||
_ => Err(format!("cannot convert a {} to a boolean",
|
||||
ast.car.to_type())),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue