[plt-scheme] Re: HTDP Exercise 12.4.2 ... Help!

From: S Brown (ontheheap at gmail.com)
Date: Sun Apr 26 13:19:20 EDT 2009

Thanks for the input so far. I don't know how I didn't see this
before! Instead of calling append on (list s) (first a-low), what I
need is to call append on another function which takes as it's
arguments a symbol and a single word, which returns a list of words
where the symbol has been been inserted before and after each letter
in the word. In other words, where insert-everywhere/in-all-words is
concerned with a list of words, my new function is only concerned with
a single word.

So, now it's a matter of going through the design process for my new
function, which I'm going to call insert-everywhere.

;; insert-everywhere: symbol word  ->  list-of-words
;; to create a list-of-words where symbol s is inserted before
;; and after each letter in the word w
(define (insert-everywhere s w)
      ((empty? w) ... s ...)
      (else ... s (first w) ...
            ... (insert-everywhere s (rest w)) ...)))

I think this makes sense. Now it's a matter of completing each cond
line in my new function insert-everywhere.. and figuring out how to
actually insert a letter into each position of a word.

Posted on the users mailing list.