Pascal answered my post very well. I don't want to annoy anyone with the
new thread so his response is below.
Thanks again, Pascal.
[... Pascal's Response ...]
Not at all. Indeed, I went over the definition of the interface of
the function what somewhat quickly.
The point here is that when we write (collect what where), to be able
to work, the function collect needs to know several things from what;
it needs to know:
- what is the first item?
- what is the other items (the rest)?
- when there is no remaining items?
There are several possibilities for a single function to return all
I made the choice of adding a selector parameter to the 'what'
function. For this selector, I used symbols first and rest. (At
first, I had an additionnal selector empty?, but I eventually merged
it with first, which now returns a list of 0 or 1 item, 0 when the
sentence is empty, when there remains no items).
The model here is that of objects receiving messages, the symbol first
and rest being the message sent to the 'what' object, with the where
But we could do it all at once:
(define (what sentence)
and we'd then write collect as:
(define (collect what where)
(let ((step (what where)))
(if (first step)
(cons (second step) (what (third step)))
Which indeed gives a simplier solution, and avoids some duplication in
the what functions.
__Pascal Bourguignon__ http://www.informatimago.com/
NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently