CSE536 Functional Programming, Lecture Notes
The following are powerpoint slides (and associated code) from the lectures.
All lectures are listed. The slides will be become available the day of the
lecture.
- September 27, 2004
- September, 29, 2004.
- October 4, 2004.
- Slides:
Usefull pre-defined functions on lists.
Data-Type declarations,
Defining functions over datatypes using patterns,
Enumerations,
and the Shape Datatype of the text.
This lecture defines the
module Shape
- Haskell Code:
Day, valday, dayval, Move, beats, Direction,
Tagger, isNum, Temp, toKelvin, Shape, circle, square, area, triArea, distBetween etc.
- October 6, 2004.
- Slides:
Homework #1 Solutions,
Program Manipulation,
Comparing the functional paradigm,
Actions and Haskell,
Monads,
Simple Graphics.
- Homework #1 examples
- Haskell Code:
strlen, fact, ncopies, power, str2int, explist, Bintree, leftmost, replace, replace', ex2,
getline', wc, ex7, spaceclose,
etc.
- October 11, 2004
- Slides:
Using the graphics primitives,
Drawing Primitive Shapes,
Sierpinski’s Triangle,
Snow-flake,
Coordinate Systems,
Position independent shapes,
Drawing the Shape Data-type.
This lecture defines the
module Draw
- Haskell Code:
fillTri, sierpinskiTri,drawPloy,eqTri,drawStar,
snow1,snow2,snow3,sh1,sh2,sh3,sh4,ColoredShapes,
drawShapes etc.
- October 13, 2004
- Slides:
Polymorphic Functions,
Polymorphic datatypes,
Type Constructors define polymorphic Constructor functions,
Recursive datatypes,
Higher Order functions,
Perimeters of Shapes.
- Haskell Code:
len,tag1,Option,pos,Pair,Pair2,Mylist,Twolist,append2,rev2,Nat,twoNat,
mymap,myfoldr,applyTwice.,z,concat1
concat2,perimeter,sides, side2, nextEl.
- October 18, 2004
- Slides:
Trees,
Kinds of trees - branching factor,
functions over trees,
flattening a tree -- use of accumulating parameter,
patterns of recursion - the fold for trees,
Arithmetic expressions,
Infinite trees.
- Haskell Code: Tree, IntegerTree, SimpleTree, InternalTree, FancyTree, mapTree, fringe, treeSize, treeHeight, foldTreee, Expr2, Expr, evaluate, sumFromN, sumAll, add1, sumAll2,
showE, Region.
- October 20, 2004
- Slides:
Sets and characteristic functions,
Regions,
Is a point in a Region?,
Currying,
Sections,
Anonymous functions,
function composition.
This lecture defines the
module Region
- Haskell Code:
Set, even, union, intersect, complement.
Region, Vector, Ray, isLeftOf, containsS,
containsR, simple, totalSquareArea.
- October 25, 2004 -- Guest Lecture by Tom Harke.
- Slides:
Review of Proofs by calculation,
Structure of Proofs by induction over lists,
Proofs by induction with case analysis,
Proofs by structural Induction,
Proofs by induction over Trees.
- There is no Haskell Code associted with this
lecture, but there are additional sildes on using
proof by induction to prove things about programs
here:
Using Calculation to prove 2 functions are equal,
An example from class drawPic,
Laws about Monads,
Laws about sequence,
Using Calculation to improve functions,
An example from the first Homework assignment.
- Special Friday Lecture. October 29, 2004
- Slides:
Pictures,
Low level graphics bit-maps: G.Region,
From Region to G.Region,
Shape to G.Region,
Drawing G.Region,
Reactive Pictures.
This lecture defines the
module Picture
- Haskell Code:
Picture, regionToGRegion,shapeToGRegion,
drawRegionInWindow,drawPic,draw,spaceClose
- November 1, 2004. Guest Lecture by Tom Harke.
- Slides:
The Haskell Class system,
Instance declarations,
Inheritance and dependent classes,
Derived instances,
The Show class,
The Fix operator from homework #5.
- Haskell Code:
Eq,Aop,Aexp,aop_eq,aexp_eq.
Complex, complex_add, complex_sub, complex_mult.
Num, Ord, Tree, Mylist, int_list_eq, list_eq.
Bush, Show, showTree, showsTree, showsList.
Color, Exp, member, fix.
- November 3, 2004. Midterm Exam. Open Book.
- November 8, 2004
- Slides:
Simple animations,
Buffered graphics,
Animations in Haskell,
Complex animations,
Lifting primitives to animations,
Behaviors,
Type classes animations and Behaviors,
Time translation.
- Haskell Code:
Animation, Time,rubberBall,revolvingBall, Planets,
animate,regionToGraphic,picToGraphic. Behavior, lift0,
lift1, lift2. Instance defintions for Behavior(Num,Fractional,Floating). Class Ani with methods "empty" and "over". Instances for Ani([ ],
(->), Picture,Behavior). timeTrans, ifFun, cond, animate2. Class Turnable, rotate, kaleido, spectrum.
This lecture defines the module Animation.
- November 10, 2004
- Slides:
Infinite lists v.s. Streams,
Normal order evaluation,
Recursive streams,
Stream Diagrams,
Lazy patterns,
Memoization,
Inductive properties of infinite lists.
- Haskell Code:
Stream, twos, ignore, fibA, fibs, counter, ifx, followedby,
Response, Request, client, server, reqs, resps, fibsFn, memo1.
The memo function memo1 can be found in the memo library.
- November 15, 2004
- Slides:
Simple Animations - Review.
Reactive animations.
Vocabulary.
Examples.
Implementation of behaviors and events.
- Haskell Code:
This lecture defines the
module Fal.
- November 29, 2004
- Slides:
Files, Channels, and Handles.
IO exception handling.
First Class Channels.
Concurrency and ForkIO.
- Haskell Code:
- December 1, 2004. lecture 17
- Slides:
Higher Order types.
Type constructors that take types as arguments.
Functor,
Monad,
MonadPlus and MonadZero.
- Haskell Code:
- Dec 1 & 6, 2004, Lecture 18
- Slides:
Haskore System.
The Music datatype.
MIDI Instruments.
Pitch & absolute Pitch.
Composing Music:
Delay,
Repeating,
Transposing.
Manipulating Music:
Duration,
Cutting,
Reversing.
Percussion.
Presentation and the MIDI file format.
- Haskell Code:
- The Music Module.
- Dec 6, 2004. Lecture 19
Back to CSE536 Home Page