fork download
  1. (defun vowel-p (char)
  2. (member char '(#\a #\e #\i #\o #\u) :test #'char=))
  3.  
  4. (defun split-word (word)
  5. (let ((chars (coerce word 'list))
  6. (syllables nil)
  7. (current nil))
  8. (dolist (ch chars)
  9. (push ch current)
  10. (when (vowel-p ch)
  11. (push (coerce (reverse current) 'string) syllables)
  12. (setf current nil)))
  13. (when current
  14. (if syllables
  15. (setf (car syllables)
  16. (concatenate 'string (car syllables)
  17. (coerce (reverse current) 'string)))
  18. (push (coerce (reverse current) 'string) syllables)))
  19. (reverse syllables)))
  20.  
  21. (defun split-string (str)
  22. (let ((words nil) (current nil))
  23. (dotimes (i (length str))
  24. (let ((ch (char str i)))
  25. (if (char= ch #\Space)
  26. (when current
  27. (push (coerce (reverse current) 'string) words)
  28. (setf current nil))
  29. (push ch current))))
  30. (when current
  31. (push (coerce (reverse current) 'string) words))
  32. (reverse words)))
  33.  
  34. (defun split-phrase (phrase)
  35. (mapcar #'split-word (split-string phrase)))
  36.  
  37. (print (split-phrase "hello world"))
  38.  
Success #stdin #stdout #stderr 0.02s 6944KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/pKA9Yv/prog:37:36: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit