Com S 541 Lecture -*- Outline -*- * Introduction to Programming Concepts (Chapter 1) ------------------------------------------ QUIZ FOR CHAPTER 1 [system] What are the important points for working with the Mozart/Oz system? [variable] What does a "variable" mean in Oz? [function defs, recursion] The Fibonacci function is defined by Fib(0) = 1 Fib(1) = 1 Fib(n) = Fib(n-1) + Fib(n-2), if n >= 2 Write this in Oz. [correctness] Prove that your Fib function is correct. [Lazy evaluation] Make Fib run in time O(n). [lists, pattern matching] Write a function Assoc that takes a list of key-value pairs and a key K, and returns the element in the list associated with K, if any. [higher-order functions] Write a function Map that takes a function F and a list Lst and returns the list of the results of applying F to each element of Lst, in order. [threads] How are threads created? Give an example. [Dataflow] What is a dataflow variable and how is it used? Give an example. [Cells] How are memory cells created and used? Give an example. [Objects] How are objects related to functions? [Classes] Write a class for 2-dimensional points. [Nondeterminism and time] Give an example of a race condition. Does this example need to use cells? [Atomicity] How are locks used to avoid the problems with concurrency and state? Give an example. ------------------------------------------