summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo <hugo.hornquist@gmail.com>2016-04-27 21:36:01 +0200
committerHugo <hugo.hornquist@gmail.com>2016-04-27 21:36:01 +0200
commit227d822aec5cadf17c23c0af5a745424c5b07698 (patch)
treea52f2c6249d3b0b9c36ee7e03de01abc05eb2421
parentfull-parse now has some comments, moved a function (diff)
downloadmath-parse-227d822aec5cadf17c23c0af5a745424c5b07698.tar.gz
math-parse-227d822aec5cadf17c23c0af5a745424c5b07698.tar.xz
parser now handles numbers with more than one digit, inculding decimals and other fun notations
-rw-r--r--full-parse.rkt9
1 files changed, 8 insertions, 1 deletions
diff --git a/full-parse.rkt b/full-parse.rkt
index df1118c..a20583c 100644
--- a/full-parse.rkt
+++ b/full-parse.rkt
@@ -44,6 +44,13 @@
string->number string->symbol)
(string c)))
+ ; goes from a list of chars to a number
+ ; returns #f if conversion is not possible
+ (define (make-number expr)
+ (if (list? expr)
+ (string->number (list->string expr))
+ expr))
+
; creates a fucntion for the current operator,
; with a function call for the next operatior as a parameter
(define (create-trace expr ops)
@@ -51,7 +58,7 @@
;(display expr) (newline)
(get-general expr (car ops)
(if (null? (cdr ops))
- (lambda (x) x)
+ (lambda (x) (make-number x))
(create-trace expr (cdr ops))))))
; start the function, with the operations