Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (divider? ch)
- (or (equal? ch #\tab)
- (equal? ch #\newline)
- (equal? ch #\space)))
- (define (empty? str)
- (define (rec str len i)
- (or (= i len)
- (and (divider? (string-ref str i))
- (rec str len (+ i 1)))))
- (rec str (string-length str) 0))
- (define (read-words)
- (define (rec xs str)
- (let ((ch (read-char)))
- (if (eof-object? ch)
- (if (empty? str)
- xs
- (append xs (list str)))
- (if (divider? ch)
- (if (empty? str)
- (rec xs "")
- (rec (append xs (list str)) ""))
- (rec xs (string-append str (string ch)))))))
- (rec '() ""))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement