Implemented subtraction for functio chains... maybe?

pull/1/head
ondra05 2021-12-09 17:51:03 +01:00
parent 3f1b6d2387
commit 3358234914
1 changed files with 10 additions and 1 deletions

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,