Skip to content

Commit cd8dc29

Browse files
committed
Update index.ts
1 parent 8f05dc0 commit cd8dc29

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

parse-lisp-expression/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@ function calculate(expression: Expression, scope: ScopeList): number {
106106
switch (expression.type) {
107107
case "NumericLiteral":
108108
return expression.value;
109+
case "MultExpression":
110+
return (
111+
calculate(expression.left, scope) *
112+
calculate(expression.right, scope)
113+
);
114+
case "AddExpression":
115+
return (
116+
calculate(expression.left, scope) +
117+
calculate(expression.right, scope)
118+
);
109119
}
110120
throw Error("Not implemented");
111121
}

0 commit comments

Comments
 (0)