summaryrefslogtreecommitdiff
path: root/math-parser.scm
diff options
context:
space:
mode:
Diffstat (limited to 'math-parser.scm')
-rw-r--r--math-parser.scm18
1 files changed, 10 insertions, 8 deletions
diff --git a/math-parser.scm b/math-parser.scm
index 1048250..b9ef4b9 100644
--- a/math-parser.scm
+++ b/math-parser.scm
@@ -14,16 +14,16 @@
(define (inner current-term other-terms remaining-expression)
(cond
- [(null? remaining-expression)
- (add-operation-to-list current-term other-terms)]
- [(eqv? (car remaining-expression) operator)
+ ((null? remaining-expression)
+ (add-operation-to-list current-term other-terms))
+ ((eqv? (car remaining-expression) operator)
(inner '()
(add-operation-to-list current-term other-terms)
- (cdr remaining-expression))]
- [else
+ (cdr remaining-expression)))
+ (else
(inner (cons (car remaining-expression) current-term)
other-terms
- (cdr remaining-expression))]))
+ (cdr remaining-expression)))))
(if (not (contains operator expr))
@@ -59,5 +59,7 @@
; start the function, with the operations
; in order, from outermost to innermost.
- (let ((expr (string->list str)))
- ((create-trace expr '(#\+ #\- #\* #\/ #\^)) expr)))
+ (let* ((expr (string->list str))
+ (trace ((create-trace expr '(#\+ #\- #\* #\/ #\^)) expr)))
+ (if (contains-false? trace)
+ #f trace)))