<div>OK, now I can celebrate....</div> <div> </div> <div>In the solution I posted before, I accidentally put "(cons empty empty)" instead of "empty" in Helper #3, which added an unnecessary list to each word.</div> <div> </div> <div>Thanks again, cooke</div> <div> </div> <div>FINAL SOLUTION:</div> <div> </div> <div>;MAIN FUNCTION: arrangements: word --> list of words<BR> (define (arrangements a-word)<BR> (cond [(empty? a-word) (cons empty empty)]<BR> [else (insert-everywhere/in-all-words (first a-word) (arrangements (rest<BR> a-word)))]))<BR> <BR> ;HELPER #1: insert-everywhere/in-all-words : letter, list of words --> list of words<BR> (define (insert-everywhere/in-all-words s low)<BR> (cond<BR> [(empty? (rest low)) (insert-everywhere/one-word s (first low))]<BR> [else (append (insert-everywhere/one-word s
(first low)) (insert-everywhere/in-all-words s (rest low)))]))<BR> <BR> ;HELPER #2: insert-everywhere/one-word : letter, word --> list of words<BR> ;NOTE: this function just adds the last word to Helper #3<BR> (define (insert-everywhere/one-word letter a-word)<BR> (append (list (append a-word (list letter))) (insert-everywhere-except-last-letter letter a-word)))<BR> <BR> ;HELPER #3: insert-everywhere-except-last-letter : letter, word --> list of words<BR> (define (insert-everywhere-except-last-letter letter a-word)<BR> (cond<BR> [(empty? a-word) empty]<BR> [(empty? (rest a-word)) (cons (list letter (first a-word)) empty)]<BR> [else (cons (cons letter a-word) (add-first-letter (first a-word) (insert-everywhere-except-last-letter letter (rest a-word))))]))<BR> <BR> ;HELPER #4 : add-first-letter : letter, list of words --> list of
words<BR> (define (add-first-letter letter low)<BR> (cond <BR> [(empty? (rest low)) (cons (append (list letter) (first low)) empty)]<BR> [else (cons (append (list letter) (first low)) (add-first-letter letter (rest low)))]))<BR></div> <div>;test<BR>(arrangements (list 'd 'a 'r 'e))</div> <div>;result</div> <div>(list<BR> (list 'e 'r 'a 'd)<BR> (list 'd 'e 'r 'a)<BR> (list 'e 'd 'r 'a)<BR> (list 'e 'r 'd 'a)<BR> (list 'a 'e 'r 'd)<BR> (list 'd 'a 'e 'r)<BR> (list 'a 'd 'e 'r)<BR> (list 'a 'e 'd 'r)<BR> (list 'e 'a 'r 'd)<BR> (list 'd 'e 'a 'r)<BR> (list 'e 'd 'a 'r)<BR> (list 'e 'a 'd 'r)<BR> (list 'r 'e 'a 'd)<BR> (list 'd 'r 'e 'a)<BR> (list 'r 'd 'e 'a)<BR> (list 'r 'e 'd 'a)<BR> (list 'a 'r 'e 'd)<BR> (list 'd 'a 'r 'e)<BR> (list 'a 'd 'r 'e)<BR> (list 'a 'r 'd 'e)<BR> (list 'r 'a 'e 'd)<BR> (list 'd 'r 'a
'e)<BR> (list 'r 'd 'a 'e)<BR> (list 'r 'a 'd 'e))</div><p> 
<hr size=1>Like movies? Here's a limited-time offer: <a href="http://us.rd.yahoo.com/evt=47522/*http://tc.deals.yahoo.com/tc/blockbuster/text4.com
">Blockbuster Total Access</a> for one month at no cost.