; A Non-empty-List-of-Numbers is one of
; - (cons num empty)
; - (cons num Non-empty-List-of-Number)
In this case, the template looks as follows:
(define (func-for-nelon a-nelon)
(cond
[(empty? (rest a-nelon)) ..(first a-nelon)..]
[else ..(first a-nelon)..(func-for-nelon (rest a-nelon))..]))
; A Non-empty-List-of-Numbers is
; (cons num List-of-Numbers)
Here, the template is different, since it must refer to the
template for a regular (non-empty) List-of-Numbers.
In particular, you don't make a recursive call;
you think to yourself "Ah, a-nelon is a (perhaps-empty) list;
i'd better call a function for such regular ol' lists":
(define (f a-nelon) ...(first a-nelon)...(func-for-lon (rest a-nelon)...)To compute the average, what function(s) of general (perhaps-empty) lists do you want to call, as your helper?