Implement lambda application (boom!)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user