As you are preparing for lab on Tuesday, you're going to want to spend some time doing more than just reading. I, personally, struggle to learn a language from a book—I have to write code.
In writing these functions, you are working with list-based data. Specifically, you are working with structures that were built using cons. cons has the contract:
; cons : any list -> list
In a picture, it the output of cons looks like:

On the left side of the cons is the first argument: a value. In the right side of the cons is the list that we are appending to. The structure this produces in memory looks a lot like a node in a linked list. That's because, deep down, the lists are lists are lists, and this is how we build them.
Now that we've seen that, though, we'll just think of the first element of a list as the first, and the remainder of the list as the rest. You can write the contracts for first and rest yourself.
Work these four questions following the Design Recipe. Use Piazza to ask questions if you get stuck.
- Develop the function between?, which consumes three numbers and produces true if the last is between the first two, otherwise it returns false. Note this function does not traverse a list; it consumes three distinct values.
- Use between? to develop the function three-between?, which consumes two numbers and a list of three numbers and determines if all three numbers in the list are between the first two. Note this function does not actually traverse a list, but instead accesses the first three members of a list.
- Develop a function that computes the length of a list.
- Develop a function contains-true? that consumes a list of booleans and determines whether one of them is true. Consider whether empty contains a true element.
- Develop a function sum-nums that consumes a list of numbers and computes the sum of all of those numbers.
Finally, develop a list processing question yourself and post it to the list. Your question might involve a list of data structures, or a list of symbols, or a list of lists or some other kind of data. You can discuss the formulation of a problem with others, but I would like you to write up a problem statement yourself and post it to Piazza.
