In this part of the lab, we will be learning Scheme. We have provided a Javascript based scheme interpreter that will let you interpret Scheme right in your browser! You can type code into the boxes, and to run the interpreter, either click outside, or press Ctrl-Enter. Give it a try below:
If you like the in-line interpreter, check out the Interactive SICP, where you can interpret Scheme expressions while you are reading the book.
Fill in the definition for the procedure accumulate, as you have been asked to do in Homework 2:
Accumulate takes in:
combiner: A function of two arguments
start: A number to start combining with
n: The number of terms to combine
term: A function of one argument that computes the n-th term of the sequence.
And returns the result of combining the first n terms of the sequence.
Remember the tree data structure that we built in discussion.
Write a procedure num-leaves, that counts the number of leaves in a tree.