From 5ea3f730e53281d7bb68de2deca95597f9f325ba Mon Sep 17 00:00:00 2001 From: ltcptgeneral <35508619+ltcptgeneral@users.noreply.github.com> Date: Wed, 29 Apr 2020 23:02:02 -0500 Subject: [PATCH] 7 --- .../analysis-amd64/analysis/equation.ipynb | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/analysis-master/analysis-amd64/analysis/equation.ipynb b/analysis-master/analysis-amd64/analysis/equation.ipynb index b5ebf646..abe8dfd0 100644 --- a/analysis-master/analysis-amd64/analysis/equation.ipynb +++ b/analysis-master/analysis-amd64/analysis/equation.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 48, + "execution_count": 164, "metadata": {}, "outputs": [], "source": [ @@ -13,19 +13,19 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 165, "metadata": {}, "outputs": [], "source": [ "def add(string):\n", " while(len(re.findall(\"[+]{1}[-]?\", string)) != 0):\n", - " string = re.sub(\"[-]?\\d+[.]?\\d*[+]{1}[-]?\\d+[.]?\\d*\", str(sum([Decimal(i) for i in re.split(\"[+]{1}\", re.search(\"[-]?\\d+[.]?\\d*[+]{1}[-]?\\d+[.]?\\d*\", string).group())])), string, 1)\n", + " string = re.sub(\"[-]?\\d+[.]?\\d*[+]{1}[-]?\\d+[.]?\\d*\", str(\"%f\" % reduce((lambda x, y: x + y), [Decimal(i) for i in re.split(\"[+]{1}\", re.search(\"[-]?\\d+[.]?\\d*[+]{1}[-]?\\d+[.]?\\d*\", string).group())])), string, 1)\n", " return string" ] }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 166, "metadata": {}, "outputs": [], "source": [ @@ -45,43 +45,43 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 167, "metadata": {}, "outputs": [], "source": [ "def mul(string):\n", " while(len(re.findall(\"[*]{1}[-]?\", string)) != 0):\n", - " string = re.sub(\"[-]?\\d+[.]?\\d*[*]{1}[-]?\\d+[.]?\\d*\", str(reduce((lambda x, y: x * y), [Decimal(i) for i in re.split(\"[*]{1}\", re.search(\"[-]?\\d+[.]?\\d*[*]{1}[-]?\\d+[.]?\\d*\", string).group())])), string, 1)\n", + " string = re.sub(\"[-]?\\d+[.]?\\d*[*]{1}[-]?\\d+[.]?\\d*\", str(\"%f\" % reduce((lambda x, y: x * y), [Decimal(i) for i in re.split(\"[*]{1}\", re.search(\"[-]?\\d+[.]?\\d*[*]{1}[-]?\\d+[.]?\\d*\", string).group())])), string, 1)\n", " return string" ] }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 168, "metadata": {}, "outputs": [], "source": [ "def div(string):\n", " while(len(re.findall(\"[/]{1}[-]?\", string)) != 0):\n", - " string = re.sub(\"[-]?\\d+[.]?\\d*[/]{1}[-]?\\d+[.]?\\d*\", str(reduce((lambda x, y: x / y), [Decimal(i) for i in re.split(\"[/]{1}\", re.search(\"[-]?\\d+[.]?\\d*[/]{1}[-]?\\d+[.]?\\d*\", string).group())])), string, 1)\n", + " string = re.sub(\"[-]?\\d+[.]?\\d*[/]{1}[-]?\\d+[.]?\\d*\", str(\"%f\" % reduce((lambda x, y: x / y), [Decimal(i) for i in re.split(\"[/]{1}\", re.search(\"[-]?\\d+[.]?\\d*[/]{1}[-]?\\d+[.]?\\d*\", string).group())])), string, 1)\n", " return string" ] }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 169, "metadata": {}, "outputs": [], "source": [ "def exp(string):\n", " while(len(re.findall(\"[\\^]{1}[-]?\", string)) != 0):\n", - " string = re.sub(\"[-]?\\d+[.]?\\d*[\\^]{1}[-]?\\d+[.]?\\d*\", str(reduce((lambda x, y: x ** y), [Decimal(i) for i in re.split(\"[\\^]{1}\", re.search(\"[-]?\\d+[.]?\\d*[\\^]{1}[-]?\\d+[.]?\\d*\", string).group())])), string, 1)\n", + " string = re.sub(\"[-]?\\d+[.]?\\d*[\\^]{1}[-]?\\d+[.]?\\d*\", str(\"%f\" % reduce((lambda x, y: x ** y), [Decimal(i) for i in re.split(\"[\\^]{1}\", re.search(\"[-]?\\d+[.]?\\d*[\\^]{1}[-]?\\d+[.]?\\d*\", string).group())])), string, 1)\n", " return string" ] }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 170, "metadata": {}, "outputs": [], "source": [ @@ -96,27 +96,29 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": 171, "metadata": {}, "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": "-128+0.8\n" - }, { "output_type": "execute_result", "data": { - "text/plain": "'-127.2'" + "text/plain": "'-158456325028528675187087900672.000000'" }, "metadata": {}, - "execution_count": 70 + "execution_count": 171 } ], "source": [ - "string = \"8^2*4/-2+0.8\"\n", + "string = \"8^32*4/-2+0.8\"\n", "evaluate(string)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {