From b8abb977a249a4a05ede73e0e7e3fc841211b4a5 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Tue, 7 May 2024 04:29:16 +0900 Subject: [PATCH] feat: Add support for logical NOT operator in toRPN function --- src/ts/process/infunctions.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ts/process/infunctions.ts b/src/ts/process/infunctions.ts index f7490cf8..db569291 100644 --- a/src/ts/process/infunctions.ts +++ b/src/ts/process/infunctions.ts @@ -16,7 +16,8 @@ function toRPN(expression:string) { '&': {precedence: 1, associativity: 'Left'}, '≤': {precedence: 1, associativity: 'Left'}, '≥': {precedence: 1, associativity: 'Left'}, - '=': {precedence: 1, associativity: 'Left'} + '=': {precedence: 1, associativity: 'Left'}, + '!': {precedence: 5, associativity: 'Right'}, }; const operatorsKeys = Object.keys(operators); @@ -93,6 +94,7 @@ function calculateRPN(expression:string) { case '≤': stack.push(a <= b ? 1 : 0); break; case '≥': stack.push(a >= b ? 1 : 0); break; case '=': stack.push(a === b ? 1 : 0); break; + case '!': stack.push(b ? 0 : 1); break; } } });