Implemented subtraction for functio chains... maybe?

This commit is contained in:
Erin 2021-12-09 17:51:03 +01:00 committed by ondra05
parent 7aeb9d525d
commit 6f193577ab

View file

@ -501,7 +501,16 @@ impl ops::Sub for Value {
)
.into_functio(),
},
Functio::Chain { functios, kind } => todo!(),
Functio::Chain { functios, .. } => {
let rhs = rhs.into_functio();
let (a, b) = *functios;
match (a == rhs, b == rhs) {
(_, true) => a,
(true, _) => b,
(_, _) => (Value::Functio(a) - Value::Functio(rhs)).into_functio(),
}
}
Functio::Eval(lhs_code) => Functio::Eval(lhs_code.replace(
&match rhs.into_functio() {
Functio::Eval(code) => code,