Implement PartialEq and PartialOrd resolves #7
This commit is contained in:
@@ -62,20 +62,23 @@ pub fn eq(args: Vec<Datum>) -> Datum {
|
||||
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);
|
||||
}
|
||||
if first != current {
|
||||
return Boolean(false);
|
||||
}
|
||||
}
|
||||
Boolean(true)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn lt(args: Vec<Datum>) -> Datum {
|
||||
if args.len() == 1 {
|
||||
Boolean(true)
|
||||
} else {
|
||||
for i in 1..(args.len() - 1) {
|
||||
if &args[i] >= &args[i + 1] {
|
||||
return Boolean(false);
|
||||
}
|
||||
}
|
||||
Boolean(true)
|
||||
|
||||
Reference in New Issue
Block a user