fork download
  1. (defun vowel-p (char)
  2. (member char '(#\а #\е #\ё #\и #\о #\у #\ы #\э #\ю #\я
  3. #\А #\Е #\Ё #\И #\О #\У #\Ы #\Э #\Ю #\Я)
  4. :test #'char=))
  5.  
  6. (defun split-word (word)
  7. (labels ((split-chars (chars current syllables)
  8. (if (null chars)
  9. (if current
  10. (if syllables
  11. (reverse (cons (concatenate 'string
  12. (car syllables)
  13. (coerce (reverse current) 'string))
  14. (cdr syllables)))
  15. (list (coerce (reverse current) 'string)))
  16. (reverse syllables))
  17. (let ((ch (car chars)))
  18. (if (vowel-p ch)
  19. (split-chars (cdr chars)
  20. nil
  21. (cons (coerce (reverse (cons ch current)) 'string)
  22. syllables))
  23. (split-chars (cdr chars)
  24. (cons ch current)
  25. syllables))))))
  26. (split-chars (coerce word 'list) nil nil)))
  27.  
  28. (defun split-string (str)
  29. (labels ((split-chars (i current words)
  30. (if (>= i (length str))
  31. (if current
  32. (reverse (cons (coerce (reverse current) 'string) words))
  33. (reverse words))
  34. (let ((ch (char str i)))
  35. (if (char= ch #\Space)
  36. (if current
  37. (split-chars (+ i 1)
  38. nil
  39. (cons (coerce (reverse current) 'string) words))
  40. (split-chars (+ i 1) nil words))
  41. (split-chars (+ i 1)
  42. (cons ch current)
  43. words))))))
  44. (split-chars 0 nil nil)))
  45.  
  46. (defun split-phrase (phrase)
  47. (mapcar #'split-word (split-string phrase)))
  48.  
  49.  
  50. (print (split-phrase "мама мыла раму"))
  51.  
  52. (print (split-phrase "весна красивая"))
  53.  
  54. (print (split-phrase "стол стул окно"))
  55.  
  56. (print (split-phrase "дом сад лес"))
  57.  
  58. (print (split-phrase "программирование функциональное"))
  59.  
  60. (print (split-phrase "строка слово текст"))
  61.  
  62.  
Success #stdin #stdout #stderr 0.02s 9564KB
stdin
Standard input is empty
stdout
(("ма" "ма") ("мы" "ла") ("ра" "му")) 
(("ве" "сна") ("кра" "си" "ва" "я")) 
(("стол") ("стул") ("о" "кно")) 
(("дом") ("сад") ("лес")) 
(("про" "гра" "мми" "ро" "ва" "ни" "е") ("фу" "нкци" "о" "на" "льно" "е")) 
(("стро" "ка") ("сло" "во") ("текст")) 
stderr
Warning: reserving address range 0x80000c0000...0x1fffffffffff that contains memory mappings. clisp might crash later!
Memory dump:
  0x8000000000 - 0x80000bffff
  0x14b577000000 - 0x14b5772e4fff
  0x14b577400000 - 0x14b577402fff
  0x14b577403000 - 0x14b577601fff
  0x14b577602000 - 0x14b577602fff
  0x14b577603000 - 0x14b577603fff
  0x14b577615000 - 0x14b577639fff
  0x14b57763a000 - 0x14b5777acfff
  0x14b5777ad000 - 0x14b5777f5fff
  0x14b5777f6000 - 0x14b5777f8fff
  0x14b5777f9000 - 0x14b5777fbfff
  0x14b5777fc000 - 0x14b5777fffff
  0x14b577800000 - 0x14b577803fff
  0x14b577804000 - 0x14b577a03fff
  0x14b577a04000 - 0x14b577a04fff
  0x14b577a05000 - 0x14b577a05fff
  0x14b577a68000 - 0x14b577a69fff
  0x14b577a6a000 - 0x14b577a79fff
  0x14b577a7a000 - 0x14b577aadfff
  0x14b577aae000 - 0x14b577be4fff
  0x14b577be5000 - 0x14b577be5fff
  0x14b577be6000 - 0x14b577be8fff
  0x14b577be9000 - 0x14b577be9fff
  0x14b577bea000 - 0x14b577bebfff
  0x14b577bec000 - 0x14b577becfff
  0x14b577bed000 - 0x14b577beefff
  0x14b577bef000 - 0x14b577beffff
  0x14b577bf0000 - 0x14b577bf0fff
  0x14b577bf1000 - 0x14b577bf1fff
  0x14b577bf2000 - 0x14b577bfffff
  0x14b577c00000 - 0x14b577c0dfff
  0x14b577c0e000 - 0x14b577c1afff
  0x14b577c1b000 - 0x14b577c1efff
  0x14b577c1f000 - 0x14b577c1ffff
  0x14b577c20000 - 0x14b577c20fff
  0x14b577c21000 - 0x14b577c26fff
  0x14b577c27000 - 0x14b577c28fff
  0x14b577c29000 - 0x14b577c29fff
  0x14b577c2a000 - 0x14b577c2afff
  0x14b577c2b000 - 0x14b577c2bfff
  0x14b577c2c000 - 0x14b577c59fff
  0x14b577c5a000 - 0x14b577c68fff
  0x14b577c69000 - 0x14b577d0efff
  0x14b577d0f000 - 0x14b577da5fff
  0x14b577da6000 - 0x14b577da6fff
  0x14b577da7000 - 0x14b577da7fff
  0x14b577da8000 - 0x14b577dbbfff
  0x14b577dbc000 - 0x14b577de3fff
  0x14b577de4000 - 0x14b577dedfff
  0x14b577dee000 - 0x14b577deffff
  0x14b577df0000 - 0x14b577df5fff
  0x14b577df6000 - 0x14b577df8fff
  0x14b577dfb000 - 0x14b577dfbfff
  0x14b577dfc000 - 0x14b577dfcfff
  0x14b577dfd000 - 0x14b577dfdfff
  0x14b577dfe000 - 0x14b577dfefff
  0x14b577dff000 - 0x14b577dfffff
  0x14b577e00000 - 0x14b577e06fff
  0x14b577e07000 - 0x14b577e09fff
  0x14b577e0a000 - 0x14b577e0afff
  0x14b577e0b000 - 0x14b577e2bfff
  0x14b577e2c000 - 0x14b577e33fff
  0x14b577e34000 - 0x14b577e34fff
  0x14b577e35000 - 0x14b577e35fff
  0x14b577e36000 - 0x14b577e36fff
  0x555d2ea28000 - 0x555d2eb18fff
  0x555d2eb19000 - 0x555d2ec22fff
  0x555d2ec23000 - 0x555d2ec82fff
  0x555d2ec84000 - 0x555d2ecb2fff
  0x555d2ecb3000 - 0x555d2ece3fff
  0x555d2ece4000 - 0x555d2ece7fff
  0x555d2f161000 - 0x555d2f181fff
  0x7ffe01b26000 - 0x7ffe01b46fff
  0x7ffe01baf000 - 0x7ffe01bb2fff
  0x7ffe01bb3000 - 0x7ffe01bb4fff