From e7c14517c93458bbac202dee4decea6cf7799f59 Mon Sep 17 00:00:00 2001 From: Silviu Marian Udrescu Date: Sat, 25 Apr 2020 21:18:20 -0400 Subject: [PATCH] Add files via upload --- Code/RPN_to_eq.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Code/RPN_to_eq.py b/Code/RPN_to_eq.py index 79e6e90..018bc54 100644 --- a/Code/RPN_to_eq.py +++ b/Code/RPN_to_eq.py @@ -5,7 +5,7 @@ import numpy as np def RPN_to_eq(expr): variables = ["0","1","a","b","c","d","e","f","g","h","i","j","k","l","m","n","P"] - operations_1 = [">","<","~","\\","L","E","S","C","A","N","T","R"] + operations_1 = [">","<","~","\\","L","E","S","C","A","N","T","R","O","J"] operations_2 = ["+","*","-","/"] stack = np.array([]) @@ -66,4 +66,10 @@ def RPN_to_eq(expr): if i=="R": a="sqrt("+a+")" stack = np.append(stack,a) - return(stack[0]) \ No newline at end of file + if i=="O": + a="(2*("+a+"))" + stack = np.append(stack,a) + if i=="J": + a="(2*("+a+")+1)" + stack = np.append(stack,a) + return(stack[0])