diff --git a/fudge-chez.ss b/fudge-chez.ss index 785108b..bc80ecd 100644 --- a/fudge-chez.ss +++ b/fudge-chez.ss @@ -1,28 +1,24 @@ (import (rnrs)) (define get-word - (lambda (file word) + (lambda (file) (let ([c (lookahead-char file)]) - (if (char-alphabetic? c) - (begin - (get-char file) - (get-word file (string-append word (string c)))) - word)))) + (cond + [(char-alphabetic? c) + (get-char file) + (string-append (string c) (get-word file))] + [else ""])))) (define get-words (lambda (file) - (letrec ([loop - (lambda (file words) - (let ([c (lookahead-char file)]) - (cond - [(eof-object? c) words] - [(char-whitespace? c) - (get-char file) - (loop file words)] - [(char-alphabetic? c) - (loop file (cons (get-word file "") words))] - [else (error 'get-words "wtf" c)])))]) - (reverse (loop file '()))))) + (let ([c (lookahead-char file)]) + (cond + [(eof-object? c) '()] + [(char-whitespace? c) + (get-char file) + (get-words file)] + [(char-alphabetic? c) + (cons (get-word file) (get-words file))])))) (define tokenize (lambda (filename)