From be38e421866af6326fe4bf6d7de5480937f71ca8 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Thu, 25 Apr 2024 02:51:37 +0900 Subject: [PATCH] Add comparison operators < and > to calculateRPN function --- src/ts/process/infunctions.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ts/process/infunctions.ts b/src/ts/process/infunctions.ts index 90c3bb75..c8ea1a9a 100644 --- a/src/ts/process/infunctions.ts +++ b/src/ts/process/infunctions.ts @@ -9,6 +9,8 @@ function toRPN(expression:string) { '/': {precedence: 3, associativity: 'Left'}, '^': {precedence: 4, associativity: 'Left'}, '%': {precedence: 3, associativity: 'Left'}, + '<': {precedence: 1, associativity: 'Left'}, + '>': {precedence: 1, associativity: 'Left'}, }; expression = expression.replace(/\s+/g, ''); @@ -52,6 +54,8 @@ function calculateRPN(expression:string) { case '/': stack.push(a / b); break; case '^': stack.push(a ** b); break; case '%': stack.push(a % b); break; + case '<': stack.push(a < b ? 1 : 0); break; + case '>': stack.push(a > b ? 1 : 0); break; } } });