diff options
author | Hugo <hugo.hornquist@gmail.com> | 2016-04-27 21:36:01 +0200 |
---|---|---|
committer | Hugo <hugo.hornquist@gmail.com> | 2016-04-27 21:36:01 +0200 |
commit | 227d822aec5cadf17c23c0af5a745424c5b07698 (patch) | |
tree | a52f2c6249d3b0b9c36ee7e03de01abc05eb2421 | |
parent | full-parse now has some comments, moved a function (diff) | |
download | math-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.rkt | 9 |
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 |