The major topics we covered, along with a few concepts and some lecture/hw topics that covered these concepts. Accumulator-style functions (We saw this just before the last midterm; you might be asked to write some on this exam.) Generative recursion You recur not on a sub-structure of the input, but on some new, generated value. You lose the template's automatic guarantee of termination (you may be able to prove termination through other methods -- as we loosely argued regarding binary search) - counting from 0 *upward* to 10. - the function "threes" from hw02/lab - the hi/lo game (binary search) - miss&cann - adaptive integral Higher-order functions, abstracting patterns A function can accept not just numbers/lists/etc as input, but even other functions. Moreover, you can even have a function return functions which it creates. These allow you to abstract patterns: when you start realizing that you are writing the same code over and over, circle the parts that vary. Then, place the part that stays the same into a function, and provide as arguments the parts that vary. - adaptive integral - compose, iterate - lock-object - abstracting the comparison-operator out of sorting, abstracting loops into fori=, etc. - make-lists-fun Scope, and "local". This also involves the ideas of scope. Remember the rules for local: For each "define" in the local, (a) rename the placeholder with a unique, never-to-be-used-again name throughout the 'local' definitions & body. (b) "lift" the re-named definition to the top level. Interaction between "local" and "lambda". - password-object Mutating structures, circular structures - the cave assignment - paths through graphs (the airline-path-finder in lecture) History and remembering-state with assignment (set!) - History of all calls to add-item remembered with "total-inventory" - Remembering state (password-object, remembering to disable tampered objects) Using a for-loop; - Whenever you want to do a task involving i (for i being (say) 0,1,2,...,99) the for-loop abstracts out the code which makes sure i takes on the values 0,1,2,...,99, letting you concentrate on the specific task (involving i). Examples: - Setting (or inspecting) elements of a vector; - The jail-cell problem. The JAM2000 machine - Its architecture: main memory, registers (incl. PC), CPU. - The four-step cycle of the CPU. - The encoding/decoding of instructions. - Simple programs (fetching/storing values from memory) - Loops (branch statements) Be able to convert code between scheme, Jam, and C, including - How to define and use "fori=" in Scheme (you might not be given this code), - Converting natural-recursion to tail recursion, - Converting tail recursion to for-loops, - Writing for-loops in JAM. There may be questions involving the Jam2000 machine, but if so you'll be provided with the reference sheet (as passed out in lecture, and available from the readings page). There may be a *small* amount involving C code, but you won't need to worry about semicolons, magic lines like "#include ...", whether boolean values are declared with "bool" or with "boolean"; but you will be responsible for variable declarations, encoding function contracts as part of the language, as well as regular good program design (decomposing a big task into functions, meaningful names, reasonable indentation)