(defun vowel-p (char) (member char '(#\а #\е #\ё #\и #\о #\у #\ы #\э #\ю #\я #\А #\Е #\Ё #\И #\О #\У #\Ы #\Э #\Ю #\Я) :test #'char=)) (defun split-word (word) (labels ((split-chars (chars current syllables) (if (null chars) (if current (if syllables (reverse (cons (concatenate 'string (car syllables) (coerce (reverse current) 'string)) (cdr syllables))) (list (coerce (reverse current) 'string))) (reverse syllables)) (let ((ch (car chars))) (if (vowel-p ch) (split-chars (cdr chars) nil (cons (coerce (reverse (cons ch current)) 'string) syllables)) (split-chars (cdr chars) (cons ch current) syllables)))))) (split-chars (coerce word 'list) nil nil))) (defun split-string (str) (labels ((split-chars (i current words) (if (>= i (length str)) (if current (reverse (cons (coerce (reverse current) 'string) words)) (reverse words)) (let ((ch (char str i))) (if (char= ch #\Space) (if current (split-chars (+ i 1) nil (cons (coerce (reverse current) 'string) words)) (split-chars (+ i 1) nil words)) (split-chars (+ i 1) (cons ch current) words)))))) (split-chars 0 nil nil))) (defun split-phrase (phrase) (mapcar #'split-word (split-string phrase))) (print (split-phrase "мама мыла раму")) (print (split-phrase "весна красивая")) (print (split-phrase "стол стул окно")) (print (split-phrase "дом сад лес")) (print (split-phrase "программирование функциональное")) (print (split-phrase "строка слово текст"))
Standard input is empty
(("ма" "ма") ("мы" "ла") ("ра" "му"))
(("ве" "сна") ("кра" "си" "ва" "я"))
(("стол") ("стул") ("о" "кно"))
(("дом") ("сад") ("лес"))
(("про" "гра" "мми" "ро" "ва" "ни" "е") ("фу" "нкци" "о" "на" "льно" "е"))
(("стро" "ка") ("сло" "во") ("текст"))
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