[racket] arrangements exercise

From: Stephen Bloch (bloch at adelphi.edu)
Date: Thu Jul 12 17:14:26 EDT 2012

On Jul 12, 2012, at 4:40 PM, Sean Kemplay wrote:

> Ok, here is another shot - this time, like arrangements, making a list
> of words from the base case of insert-everywhere/in-all-words to feed
> to make words.

Lovely.  Contracts and test cases for each function, each function does a clearly-specified job, and it works.

The only quibble I would raise is with the purpose statement for "make-words":
> ;; make-words symbol list of words -> list of words
> ;; Given a symbol and a list of (partial) words, start
> ;; back filling with the symbol producing a new list of words

What dos this mean?

> (check-expect (make-words 'b empty) empty)
> (check-expect (make-words 'b '((a))) '((b a)))
> (check-expect (make-words 'c '((b a) (a))) '((c b a) (c a)))

Ah: this makes it clearer.  "make-words" adds the given symbol at the front of each of the given words.  Maybe a better name would be "cons-each".

Stephen Bloch
sbloch at adelphi.edu

Posted on the users mailing list.