[racket] Style mistakes (was: static variables question)

From: Stephen Bloch (bloch at adelphi.edu)
Date: Tue Feb 21 21:01:24 EST 2012

On Feb 21, 2012, at 6:24 PM, Don Blaheta wrote:

> As an alternative, when I was teaching from HtDP last year I used the
> pattern
> 
> (define (list-blah lst)
>  (cond [(empty? lst) ...]
>        [(cons? lst)  (cons-blah lst)]))
> 
> (define (cons-blah lst)
>  (combiner (blah (first lst))
>            (list-blah (rest lst))))

Yes, I've done that too.  In fact, the "lists" chapter of _Picturing Programs_ introduces the two-function version and then discusses "collapsing" it into one function.  What I've said in class is "if the two-function version makes more sense to you, do it that way.  If the one-function version makes more sense to you, do it that way."  Although for some data structures (e.g. n-ary trees) you NEED multiple functions.



Stephen Bloch
sbloch at adelphi.edu



Posted on the users mailing list.