From a9d9c7aa2754c67d46c2e0ebbf92f15d73cd5fab Mon Sep 17 00:00:00 2001 From: Erin Date: Thu, 9 Dec 2021 17:51:03 +0100 Subject: [PATCH] Implemented subtraction for functio chains... maybe? --- ablescript/src/variables.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ablescript/src/variables.rs b/ablescript/src/variables.rs index f16f94c4..11782976 100644 --- a/ablescript/src/variables.rs +++ b/ablescript/src/variables.rs @@ -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,