Chapter 4, HtDP.
Note: I've seen this in other questions as well.
Is it for a clarity reason or an algorithmic reason, that I am unaware of, that the base case returns empty instead of the list itself which is empty.
Example:
; List-of-numbers -> List-of-numbers
; compute the weekly wages for all given weekly hours
(define (wage* alon)
(cond
[(empty? alon) empty] ;<---- see here
[else (cons (wage (first alon)) (wage* (rest alon)))]))
; Number -> Number
; compute the wage for h hours of work
(define (wage h)
(* 12 h))
I would think this is just as correct.
; List-of-numbers -> List-of-numbers
; compute the weekly wages for all given weekly hours
(define (wage* alon)
(cond
[(empty? alon) alon] ;<---- see here
[else (cons (wage (first alon)) (wage* (rest alon)))]))
; Number -> Number
; compute the wage for h hours of work
(define (wage h)
(* 12 h))