[plt-scheme] HTDP 12.4.2
No deal. It's not what you need according to the design.
Let's try this: formulate a precise purpose statement for intersperse
and apply it to
(intersperse letter (rest word))
i.e., the recursive call. Perhaps you will then see what you have to do
with the result to get what you want for
(intersperse letter word)
i.e., the original call. Now keep in mind that you must use the same
words to describe both. It just has to fall out for the case above.
-- Matthias
On Jun 23, 2006, at 7:36 PM, wooks wooks wrote:
>
> If the recursive call
>
> (interperse sym (rest word))
>
> were to take values as follows
>
> sym (rest word)
>
> df ark
> daf rk
> darf k
> darkf empty
>
> then I'd be smoking - but that means that the contract for interperse
> has to change to
>
> interperse : word word : list-of-words
>
> So I'd use (first word) by inserting it in the penultimate position in
> sym right before the recursive call.
>
> Deal or no deal?
>
> ----Original Message Follows----
> From: Matthias Felleisen <matthias at ccs.neu.edu>
> To: "wooks wooks" <wookiz at hotmail.com>
> CC: plt-scheme at list.cs.brown.edu
> Subject: Re: [plt-scheme] HTDP 12.4.2
> Date: Fri, 23 Jun 2006 18:35:48 -0400
>
> Much easier. Put (first word) back on.
>
> On Jun 23, 2006, at 6:21 PM, wooks wooks wrote:
>
>>
>>
>> The only thing I can see is that (first word) is not being used but I
>> can't see where to slot it.
>> My best idea yet is another auxiliary function to collate all
>> substrings of word that start from the beginnig of word and to merge
>> that with the output I am getting below.
>>
>>
>>
>> ----Original Message Follows----
>> From: Matthias Felleisen <matthias at ccs.neu.edu>
>> To: "wooks wooks" <wookiz at hotmail.com>
>> CC: plt-scheme at list.cs.brown.edu
>> Subject: Re: [plt-scheme] HTDP 12.4.2
>> Date: Fri, 23 Jun 2006 15:15:08 -0400
>>
>>
>> On Jun 23, 2006, at 3:05 PM, wooks wooks wrote:
>>
>>> (interperse 'f (list 'd 'a 'r 'k))
>>>
>>> gives
>>>
>>> (list (list 'f 'd 'a 'r 'k) (list 'f 'a 'r 'k) (list 'f 'r 'k) (list
>>> 'f 'k) 'f)
>>>
>>> and I want
>>>
>>> (list (list 'f 'd 'a 'r 'k) (list 'd 'f 'a 'r 'k) (list 'd 'a 'f 'r
>>> 'k) (list 'd 'a 'r 'f 'k) (list 'd 'a 'r 'k 'f))
>>
>> Change the formating of the two things and take a close look:
>>
>> (list (list 'f 'd 'a 'r 'k) (list 'f 'a 'r 'k) (list 'f 'r 'k)
>> (list 'f 'k) 'f)
>> (list (list 'f 'd 'a 'r 'k) (list 'd 'f 'a 'r 'k) (list 'd 'a 'f 'r
>> 'k) (list 'd 'a 'r 'f 'k) (list 'd 'a 'r 'k 'f))
>>
>> When you recur with (rest word) you are dropping the first letter, at
>> each stage. So not surprisingly, the prefix is lost.
>>
>> Try with an example of length two and see whether you can come up
>> with a better idea.
>>
>>
>
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme