Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWWDillingham WesleyDillingham <wwdillingham@sugarlabs.org>2009-06-30 23:10:54 (GMT)
committer WWDillingham WesleyDillingham <wwdillingham@sugarlabs.org>2009-06-30 23:10:54 (GMT)
commitde38541e15e07959b9cef435be3390aa5c27b23f (patch)
treecd97fb1ce02f1d59b2987869c8c3d5c966e2cde2
parent767eafc2c3481ca1958eee0d977bc57412d4d278 (diff)
Accounting for ONLY Multiplication now
-rw-r--r--order_of_operations_parser.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/order_of_operations_parser.php b/order_of_operations_parser.php
index 01f83e1..a8a8089 100644
--- a/order_of_operations_parser.php
+++ b/order_of_operations_parser.php
@@ -102,7 +102,7 @@ for (i=0;i<=$numRecords;i++)
//******************************************SUBTRACTION********************************
- //TODO: account for negative numbers
+//TODO: account for negative numbers
//contains subtraction
$regexp = "-"; //NOTE:operation remains the same, as we are checking it four times for each operation
@@ -116,7 +116,7 @@ for (i=0;i<=$numRecords;i++)
}
}
- //Matches operations with ONLY SUBTRACTION
+ //Matches equations with ONLY SUBTRACTION
if (preg_match($regexp, $equation) && !preg_match("+", $equation), && !preg_match("/", $equation), && !preg_match("*", $equation))
{
$only_subtraction[tok[2]]++
@@ -141,7 +141,7 @@ for (i=0;i<=$numRecords;i++)
}
- //Matches operations with ONLY DIVISION
+ //Matches equations with ONLY DIVISION
if (preg_match($regexp, $equation) && !preg_match("+", $equation), && !preg_match("-", $equation), && !preg_match("*", $equation))
{
$only_division[tok[2]]++
@@ -151,8 +151,10 @@ for (i=0;i<=$numRecords;i++)
$only_division_correct[tok[0]]++;
}
}
-
- $regexp = "*"
+ //**************************************Multiplication*************************
+
+
+ $regexp = "*" //Matches equations with only multiplication
if (preg_match($regexp, $equation))
{
$contains_multiplication[tok[0]]++;
@@ -162,6 +164,17 @@ for (i=0;i<=$numRecords;i++)
$contains_multiplication_correct[tok[0]]++;
}
}
+
+ //Matches equations with ONLY Multiplication
+ if (preg_match($regexp, $equation) && !preg_match("+", $equation), && !preg_match("/", $equation), && !preg_match("-", $equation))
+ {
+ $only_multiplication[tok[2]]++;
+
+ if ($tok[3] = "1") //is it also correct? put it in a different associative array with the same key
+ {
+ $only_multiplication_correct[tok[0]]++;
+ }
+ }