From 227d822aec5cadf17c23c0af5a745424c5b07698 Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 27 Apr 2016 21:36:01 +0200 Subject: parser now handles numbers with more than one digit, inculding decimals and other fun notations --- full-parse.rkt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3