Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. (define (divider? ch)
  2. (or (equal? ch #\tab)
  3. (equal? ch #\newline)
  4. (equal? ch #\space)))
  5.  
  6. (define (empty? str)
  7. (define (rec str len i)
  8. (or (= i len)
  9. (and (divider? (string-ref str i))
  10. (rec str len (+ i 1)))))
  11. (rec str (string-length str) 0))
  12.  
  13. (define (read-words)
  14. (define (rec xs str)
  15. (let ((ch (read-char)))
  16. (if (eof-object? ch)
  17. (if (empty? str)
  18. xs
  19. (append xs (list str)))
  20. (if (divider? ch)
  21. (if (empty? str)
  22. (rec xs "")
  23. (rec (append xs (list str)) ""))
  24. (rec xs (string-append str (string ch)))))))
  25. (rec '() ""))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement