CS 342 Review of Part 3 (Functional Programming) * Scheme ** Goals *** What are the goals of Scheme? Does Scheme meet those goals? *** What are the differences between Scheme and LISP? ** Lambda *** What does lambda do? What does lambda do that define in LISP didn't? *** What is a closure? What is a first-class function? **** How is a closure constructed? **** How can closures be used to implement own variables? *** What are the rules of expression evaluation in Scheme? **** What role do environments play in evaluation in Scheme? **** How is the environment of a closure used in applying a closure? **** Why is the operator position of an application evaluated in Scheme? *** What is a curried function? **** Can any function be curried? **** Is curry a curried function? **** How is (curry +) related to +? *** What is a continuation? What is a continuation used for? ** Scope *** What kinds of things have scope? What is a scope? *** What is a hole in the scope? *** What are the two kinds of scope rules? Which is used in Scheme *** Give an example of a Scheme program that would give different results with different scope rules *** What are the advantages of static scoping (vs. dynamic)? ** Scheme Interpreter *** How does the Scheme interpreter differ from the LISP interpreter? **** How are closures implemented? * ML ** types *** What is the notation for a list type? Why do lists have to be homogeneous? *** What is the notation for a function type? What does it mean? ** type checking (and inference) *** What kind of security does type checking provide? *** What's the relationship between type declarations and documentation? *** How are applications type checked? *** How is the type of a function (lambda expression) inferred? *** How is an if expression type checked? ** polymorphism *** What is a polymorphic type? *** What is the type of mapcar? What is the type of combine? ** How can one use types to help write (or check) functional programs? * SASL ** Goals *** What are the goals of SASL? Does it meet them? *** How does SASL compare with Scheme? ** Lazy evaluation *** What is lazy evaluation? **** Why is it useful? **** Categorize different examples of lazy evaluation in SASL. **** How does lazy evaluation help in programming? **** What new ways of putting programs together are allowed by SASL? *** Is Scheme a lazy (normal order, call by name) language? Is SASL? *** How do the rules for evaluation of expressions in SASL differ from Scheme? **** When are thunks formed in evaluation of expressions? **** When are values demanded in evaluation of expressions? **** What problems do side-effects cause for lazy evaluation? *** What is a thunk? **** How is it implemented? **** How do thunks differ from closures? In what ways are they the same? **** Could you simulate a SASL program by a Scheme program? *** What is a strict function? ** Interpreter *** How does the SASL interpreter differ from Scheme? *** Why aren't the values of thunks printed by SASL? ** What is a recursion scheme? *** Why is it useful? ** What is a ZF expression? *** What type of value does a ZF expression construct? *** Why does SASL include ZF expressions? * Lambda Calculus ** Is the lambda calculus a lazy (normal order) language? *** Why are booleans, integers, and "if" left out of the lambda calculus? *** What actually happens in the lambda calculus? ** Formal definitions *** What is a free variable? A bound variable? *** Describe the rules for syntactic substitution on each type of expression. ** Equational theory *** What idea of programming is embodied in the alpha rule? *** In what way is the beta rule like the SASL interpreter's application code? *** What idea of programming is embodied in the beta rule? **** Under what conditions can the beta rule be used to reason about Scheme? **** How is lambda abstraction (abstracting out variables) related to beta? *** What idea of programming is embodied in the eta rule? *** What is referential transparency? **** Why is it important? **** Give an example of a program that is not referentially transparent. **** Are all Scheme programs referentially transparent? * Functional Programming in general ** Is functional programming better than imperative (e.g. Pascal) programming? ** How does functional programming differ from programming with larger values? ** Are there any problems with functional programming? ** Can you write a functional program in Pascal? Why or why not?