Last updated: Thu, 12 Feb 2015 10:47:33 -0500
HTDP/2e, Part VI, Chapters 36-39
We are jumping ahead in the textbook, so ignore the generative recursion parts for now (e.g., Chapters 36.2, 38.2, 38.3)
Understand how accumulators address the "loss of knowledge" in some functions by capturing additional context information.
Understand when and how to use accumulators.
Understand the expected style of accumulator-style functions.
; A BinaryTreeOf<X> (BTreeOf<X>) is one of: ; - X ; - (make-tree BTreeOf<X> BTreeOf<X>) ; Represents a binary tree where the X elements are stored at the leaves. ; A Depth is a Natural ; Representing the number of steps from the root of a tree to a node. ; bt-depths : BTreeOf<X> -> BTreeOf<Depth> ; Replaces the value at each node in bt with its depth. ; The root node has depth 0. (define (bt-depths bt) ...)