On Feb 13, 11:40 pm, Peteris Krumins <peteris.krum...@gmail.com>
wrote:
> Any ideas what "a function's structure" and "argument's structure"
> are? And how do they coincide or not coincide?
>
> Here is the original function:
>
> (define rember
> (lambda (a lat)
> (cond
> ((null? lat) '())
> ((eq? (car lat) a) (cdr lat))
> (else (cond
> ((eq? (car lat) a) (cdr lat))
> (else (cons (car lat)
> (rember a (cdr lat)))))))))
This is not the original function: you've inserted the second clause
of the cond expression. A list is either null, or a cons of something
onto a list. That is the structure of the argument, and so should be
the basis for the structure of the function. Since the argument can
take on one of exactly two forms, the function should naturally handle
exactly those two forms. The structure of the argument informs the
nature of the recursion in the function definition.
Once you have accounted for all possible forms your argument(s) can
take on, then you can think about transformations that preserve the
meaning of your function.
Anthony
