I know the basic algorithm for this problem but I am having trouble changing the sentence into a list inside my conditional. I created make-list to make it easier on myself but I'm not sure where to put it in the code. For ex, in the first cond statement, I need the sentence to be a list before I check if the first element in the sentence is a vowel.. but I have been doing it syntactically wrong.
vowel-ci? returns #t if a character is a case insensitive vowel, and #f otherwise.
stenotype takes a sentence and returns it with all vowels removed.
(define make-list
(lambda (string)
(string->list string)))
(define stenotype
(lambda (sentence)
(cond
[(vowel-ci? (car sentence)) (stenotype (cdr sentence))]
[else (cons (car sentence) (stenotype (cdr sentence)))])))
You need to convert the string to a list only once and filter out the vowels using
map
or recursion. The following procedure shows how to usemap
:This one is recursive and avoids
set!
andappend
:Usage:
There are a few different tasks (preparing input so it can be processed by your implementation and the processing itself), which you've broken into two different functions. The next step is combining the functions, rather than rewriting the latter to use the former. The simplest way of combining functions is composition. Compose
make-list
andstenotype
(you may wish to name this composition) and you'll have your solution.Note that you're missing a base case in
stenotype
to end the recursion.