[racket] Tabulate from build-list
Hello,
I am looking at the exercise from htdp 1e on building the tabulate
function from build-list.
Would I be on the right track that I need to create a function to
reverse the result of (build-list (+ n 1) f) to do this?
the function this is to emulate -
;; tabulate : (x -> y) x -> (listof y)
;; to tabulate f between n
;; and 0 (inclusive) in a list
(define (tabulate f n)
(cond
[(= n 0) (list (f 0))]
[else
(cons (f n)
(tabulate f (sub1 n)))]))
Using build-list
;; build-list : N (N -> X) -> (listof X)
;; to construct (list (f 0) ... (f (- n 1)))
(define (build-list n f) ...)
Regards,
Sean