Guest User

Untitled

a guest
Jul 2nd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. (require 'cl-ppcre)
  2.  
  3. (defparameter *wpm* 300)
  4. (defparameter *chunk-size* 1)
  5.  
  6. (defun tokenize(str)
  7. (cl-ppcre:split "\\s+" str))
  8.  
  9. (defun lines(file)
  10. (with-open-file (in file
  11. :direction :input
  12. :if-does-not-exist :error)
  13. (loop for line = (read-line in nil)
  14. while line
  15. collect line)))
  16.  
  17. (defun concat(lst)
  18. (apply #'concatenate 'string lst))
  19.  
  20. (defun read-words(path)
  21. (tokenize (concat (lines path))))
  22.  
  23. (defun wpm-delay(n)
  24. (/ 60.0 n))
  25.  
  26. (defun rsvp(path wpm chunk)
  27. (let* ((book (read-words path))
  28. (ch chunk)
  29. (book-len (length book)))
  30. (do* ((n 0 (1+ ch))
  31. (words book (nthcdr ch book)))
  32. ((>= ch (- book-len n))(print (subseq words n)))
  33. (print (subseq words n (+ n ch)))
  34. (sleep (wpm-delay wpm)))))
Add Comment
Please, Sign In to add comment