From 6f193577ab8bb8d9dd7f8661d7fd121e53b490a3 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 f16f94c..1178297 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,