Fully fledged lambdas, along with efficiency tweaks across the ast

This commit is contained in:
Ava Apples Affine 2023-03-13 15:02:19 -07:00
parent b0bd369c1d
commit 8efa1dbaad
Signed by: affine
GPG key ID: 3A4645B8CF806069
10 changed files with 264 additions and 70 deletions

View file

@ -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())),
}
}