TOPICS FOR THE COP 4020 EXAM on Haskell and Functional Programming $Date: 2013/02/25 16:14:11 $ This exam covers topics from homeworks 1, 3, and 4, including functional programming in Haskell. The main focus will be on topics related to homework 3 and homework 4, problems 1-3. It is related to all the course objectives but especially to [Concepts], [UseModels], and [MapToLanguages]. REMINDERS The exam will be open book, open notes, but no electronics. If you need electronic material, print it and bring the printout. (Warning: don't expect to learn the material during the exam. A good idea for studying is to condense your notes to a few pages of ready reference materials. We suggest that you memorize the Haskell syntax you'll need.) If you need more space, use the back of a page. Note when you do that on the front. Before you begin, please take a moment to look over the entire test so that you can budget your time. Clarity is important; if your programs are sloppy and hard to read, you may lose some points. Correct syntax also makes a difference for programming questions. Take special care with indentation and capitalization in Haskell. When you write Haskell code on this test, you may use anything we have mentioned in class that is built-in to Haskell. But unless specifically directed, you should not use imperative features (such as the IO type). You are encouraged to define functions not specifically asked for if they are useful to your programming; however, if they are not in the standard Haskell Prelude, then you must write them into your test. (That is, your code may not import modules other than the Prelude.) HINTS If you use functions like filter, map, and foldr whenever possible, then you will have to write less code on the test, which will mean fewer chances for making mistakes and will leave you more time to be careful. The problem will note explicitly if you are prohibited from using such functions, but by default you can. In the "follow the grammar" problems the examples may be very extensive and take a long time to read if you read every detail. But the basic idea of the recursion is usually clear from the description, simple examples, and the "follow the grammar" idea of recursing everywhere possible. So look to the examples to confirm your understanding and don't spend too much time reading examples after you understand the problem. READINGS You may want to read a tutorial on Haskell or the Haskell Language Specification. If you have time, see the course web site and also the course syllabus for other readings. TOPICS In the following, I use + to denote relatively more important topics, and - to denote relatively less important topics. Topics marked with ++ are almost certain to be on the exam. All of these are fair game, but if you have limited time, concentrate on the ones that are more important first (and in those, the ones you are most uncertain about). SKILLS [UseModels] + Haskell programming; be able to: + write simple functions that work on parts of lists, tuples, or records [HW3: invert, watching, changeChannel] + write simple functions that work on numbers, Chars, or Booleans [HW4: toCharFun] + write functions that work on (finite) flat lists with list comprehensions [HW3: add1_list_comp, deleteAll_list_comp] ++ write functions that work on (finite) flat lists (following the grammar) [HW3: add1_list_rec, deleteAll_list_rec, deleteFirst, insertBefore, listMin] [HW4: applyNeuron, applyNetwork, mapInside] + write tail-recursive functions that operate on integers or lists [HW3: listMin, whatIndex] + Know when to use (or not use) list comprehensions or library functions (especially map and filter) to solve list problems. [HW3: can you write deleteFirst using a list comprehension?] + Know when to use (or not use) tail recursion to write iterative functions. - Convert a fully recursive function into one that uses tail recursion. ++ write functions that work on recursive grammars and that follow the grammar [HW3: add1_list_rec, deleteAll_list_rec, deleteFirst, insertBefore, listMin, hep, watching, changeChannel, eqOptim, simplify, textMap] ++ write functions that work on recursive grammars that may be new to you, even if you have never previously seen that grammar [HW3: textMap] [HW4: networkApply] TERMS AND CONCEPTS [Concepts] [MapToLanguages] You should be able to explain and use (in problems or essays) the following concepts (with appropriate comparisons to related concepts). You should be able to give examples of these concepts. + Scoping: + Find the free and bound identifiers in an expression - Why is static scoping useful? - How do closures aid in static scoping? + General points about programming languages: + What is a programming language? - What is a programming model (paradigm)? - What kinds of paradigms are there? - How do languages fit within the different paradigms? + How is static typing different from dynamic typing? + What are the disadvantages and advantages of dynamic type checking, as compared to static type checking? + Haskell and declarative model concepts: + Be able to read a data definition in Haskell. + Be able to read and understand type declarations in Haskell. - What is a closure? - What is a curried function? + How to do pattern matching on lists, tuples and records in Haskell? [HW3: add1_list_rec, deleteAll_list_rec, deleteFirst, insertBefore, hep, listMin, watching, changeChannel, eqOptim, simplify, textMap] - How do variables in Haskell differ from those in Java, C, or C++? + Syntactic sugars: - What is a syntactic sugar? Give examples from Haskell. + Semantics related to the declarative model - Are programs in Haskell's declarative model necessarily deterministic? + What is a curried function? + Full recursion versus tail recursion: + Identify whether a function is tail recursive or not