Skip to content

Commit 8ffc866

Browse files
committed
add generic multiply and add
1 parent 42ceb0c commit 8ffc866

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

utils/QueryProcessor.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ export default function QueryProcessor(query: string): string {
3737
return (left * right).toString();
3838
}
3939

40+
const multiplyPlusMatch = query
41+
.toLowerCase()
42+
.match(/what is\s*(-?\d+(?:\.\d+)?)\s*multiplied by\s*(-?\d+(?:\.\d+)?)\s*plus\s*(-?\d+(?:\.\d+)?)\?/);
43+
if (multiplyPlusMatch) {
44+
const left = Number(multiplyPlusMatch[1]);
45+
const middle = Number(multiplyPlusMatch[2]);
46+
const right = Number(multiplyPlusMatch[3]);
47+
return (left * middle + right).toString();
48+
}
49+
4050
const minusMatch = query
4151
.toLowerCase()
4252
.match(/what is\s*(-?\d+(?:\.\d+)?)\s*minus\s*(-?\d+(?:\.\d+)?)\?/);

0 commit comments

Comments
 (0)