[plt-scheme] HtDP newbie question, 12.4.2
On Mar 27, 2008, at 3:15 PM, Cooke Kelsey wrote:
> (1) At this point it becomes critical to spell out the (list ...)
> stuff, i.e., to turn the example into full-fledged Scheme data.
> Small step.
>
> (.......which Scheme displays as (cons (cons 'X (cons 'A (cons 'T
> empty))) (cons (cons 'A (cons 'X (cons 'T empty))) (cons (cons 'A
> (cons 'T (cons 'X empty))) empty)))....)
I recommend raising the language level to Beginner with List ..
> (4) And before you complete the template build a table just like
> the one above for the recursive case.
>
> First Table:
>
> s | word | (first word) | (insert-in-single-word s (rest
> word)) | expected result for (insert-... s low)
> ----------------------------------------------------------------------
> ----------------------------------
> 'X |(list 'A 'T)| 'A | (insert-in-single-word s
> (list 'T) | (list (list 'X 'A 'T) (list 'A 'X 'T) (list 'A 'T 'X))
What is the VALUE of (insert-in-single-word s (list 'T) ) ? The
purpose statement tells you!
> Table for Recursive Case:
>
> s | word | (first word) | (insert-in-single-word s (rest
> word)) | expected result for (insert-... s low)
> ----------------------------------------------------------------------
> ----------------------------------
> 'X |(list 'T)| 'T | (insert-in-single-word s empty
> | (list (list 'X 'T) (list 'T 'X))
What is the VALUE of (insert-in-single-word 'X empty) ? The purpose
statement tells you!
> I feel I am getting closer to the answer. The second table
> suggest to me that there is something about recurring down to 2
> letters and then appending the rest on.....except that I lost the
> rest of the letters.
Almost! You need to actually determine the value of these expressions
not just write down the expressions to make the leap. You're almost
there.
And don't forget: if the leap is to large, you may need yet another
helper function.
-- Matthias