[plt-scheme] HTDP 12.4.2

From: wooks wooks (wookiz at hotmail.com)
Date: Fri Jun 23 19:36:56 EDT 2006

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.
>
>




Posted on the users mailing list.