
Introduction to Programming in Haskell Lecture Notes, CMI, 2008 Madhavan Mukund Chennai Mathematical Institute https://www.cmi.ac.in/~madhavan Contents Lecture 1 ................................................................................. 1 { Basic types ..............................................................................3 { Compilers vs interpreters . 4 { Functions with multiple inputs . .4 Lecture 2 ................................................................................. 6 { Multiple definitions . 6 { Functions with guards . 7 { More on pattern matching . 8 { Computation as rewriting . .9 { Lists ...................................................................................11 Lecture 3 ................................................................................13 { Lists ...................................................................................13 { Polymorphism . 15 { The datatype Char . 17 { Strings .................................................................................18 Lecture 4 ................................................................................20 { Tuple types .............................................................................20 { Local functions | where ...............................................................21 { Functions on lists | map ...............................................................22 { Functions on lists | filter ............................................................23 Lecture 5 ................................................................................24 { Notation for lists . 24 { List comprehension . 24 { Multiple generators . 25 { Translating list comprehensions . .26 { Operators vs binary functions . 26 { Functions on lists | zip ...............................................................27 Lecture 6 ................................................................................30 { Folding functions through lists | foldr ................................................30 { Folding functions through lists | foldl ................................................31 { Folding on nonempty lists | foldr1 ...................................................33 { Accummulating values | scanl, scanr .................................................33 { Combinatorial functions on lists | initial segments . 35 { Combinatorial functions on lists | all permutations . 35 { Combinatorial functions on lists | partitions . 36 Lecture 7 ................................................................................37 { Measuring efficiency . 37 { Insertion sort . 38 { Merge sort . 39 Lecture 8 ................................................................................41 { Quicksort ...............................................................................41 { Defining complexity for arithmetic functions . 41 { Complexity of divide and conquer . 42 { Divide and conquer example | minout .................................................42 Lecture 9 ................................................................................45 { Outermost reduction and infinite data structures . 45 { Using infinite lists . 45 { Search problems . 47 Lecture 10 .............................................................................. 50 { Conditional polymorphism . .50 { Defining type classes . 52 { A nontrivial example of adding instances . 54 Lecture 11 .............................................................................. 57 { User defined datatypes . 57 { Enumerated datatypes . .57 { Datatypes with parameters . 58 { Polymorphic datatypes . 58 { Recursive datatypes . 59 { Organizing functions in modules . 60 Lecture 12 .............................................................................. 63 { Abstract datatypes . 63 { Expression evaluation using stacks . 64 { Queues .................................................................................65 { Implementing queues with two lists . 65 Lecture 13 .............................................................................. 67 { Trees ...................................................................................65 { Binary search trees . 67 Lecture 13bis ............................................................................72 { Balanced binary trees . .72 Lecture 14 .............................................................................. 76 { Tree traversals . .76 { Reconstructing trees from traversals . 76 { Input/output . 78 { Actions .................................................................................79 { Composing actions . 81 { Sequencing actions | do ...............................................................82 Lecture 15 .............................................................................. 84 { Promoting values to actions | return .................................................84 { Composing actions recursively . 84 { Exception handling . 85 { Reading and writing files . 87 Lecture 16 .............................................................................. 90 { Lazy input/output . 90 { User defined control structures . .91 { Using the Haskell compiler . 91 Lecture 17 .............................................................................. 94 { The abstract datatype Set . 94 Lecture 18 .............................................................................. 99 { The abstract datatype Set . 99 { Priority queues . ..
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages128 Page
-
File Size-