From 65bb29d40105a39d708623a801fc16f9e3faa2ea Mon Sep 17 00:00:00 2001 From: Erin Date: Tue, 7 Dec 2021 21:18:45 +0100 Subject: [PATCH] Function negation --- ablescript/src/variables.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ablescript/src/variables.rs b/ablescript/src/variables.rs index 5ee99cb6..0e0a1685 100644 --- a/ablescript/src/variables.rs +++ b/ablescript/src/variables.rs @@ -443,7 +443,27 @@ impl ops::Not for Value { Abool::Sometimes => Abool::Sometimes, Abool::Always => Abool::Never, }), - Value::Functio(_) => todo!(), + Value::Functio(f) => Value::Functio(match f { + Functio::BfFunctio { + mut instructions, + tape_len, + } => { + instructions.reverse(); + Functio::BfFunctio { + instructions, + tape_len, + } + } + Functio::AbleFunctio { + mut params, + mut body, + } => { + params.reverse(); + body.reverse(); + Functio::AbleFunctio { params, body } + } + Functio::Eval(code) => Functio::Eval(code.chars().rev().collect()), + }), Value::Cart(c) => Value::Cart( c.into_iter() .map(|(k, v)| (v.borrow().clone(), Rc::new(RefCell::new(k))))