Implement lambda application (boom!)

This commit is contained in:
2021-05-29 13:50:26 -04:00
parent b0968ba498
commit 390c5d1b48
4 changed files with 111 additions and 39 deletions

View File

@@ -56,3 +56,24 @@ pub fn sub(mut args: Vec<Datum>) -> Datum {
}
Number(r)
}
pub fn eq(args: Vec<Datum>) -> Datum {
if args.len() == 1 {
Boolean(true)
} else {
let first = &args[1];
for i in 2..args.len() {
let current = &args[i];
match (first, current) {
(Boolean(b1), Boolean(b2)) => {return Boolean(b1 == b2);},
(Number(n1), Number(n2)) => {return Boolean(n1 == n2);},
_ => {
println!("{:?} is not equal to {:?}", first, current);
return Boolean(false);
}
}
}
Boolean(true)
}
}