Notes on Functional Programming with Haskell
H. Conrad Cunningham
[email protected]
Multiparadigm Software Architecture Group
Department of Computer and Information Science
University of Mississippi
201 Weir Hall
University, Mississippi 38677 USA
School of Computer Science, Australian National University
COMP1100 Introduction to Programming and Algorithms
Semester 1, 2010
Week 2 Practical Class Exercises
Basic Unix and Haskell
Objectives
This session is an introduction to the Unix operating system
Lists
An extremely important data structure.
Lists are builtin in some languages (e.g. Haskell).
Important Lessons So Far
COMP1100 Introduction to Programming and Algorithms
Clem BakerFinch
Australian National University
Semester 1, 2010
Lists are provi
Denition
A binary search tree is one where:
Binary Search Trees
Reading: Thompson Ch.14 & 19
Every value in the left subtree is less than the root;
Every value in the right subtree is greater than the root;
The left and right subtrees are also binary s
Linear Search
In that program we represented the table as an association list and used a
linear search, proceeding through the records from beginning toward the
Search
end, until the desired item was found:
find : Database > BarCode > ( Name , Price )
C
Terminology:
A, B, C, D, E, F, G are nodes of the tree.
Trees
Reading: Thompson Ch.14
A is the root of the tree.
A
E is the parent of F and G.
F and G are children of E.
B
A leaf is a node with no children.
COMP1100 Introduction to Programming and Al
Program Efciency
Complexity:
Counting the Cost
Reading: Thompson Ch.19
COMP1100 Introduction to Programming and Algorithms
Clem BakerFinch
Australian National University
Semester 1, 2010
Program correctness is obviously of primary importance.
Often, the
Proof and Haskell
Proof is easier in functional languages.
Reasoning About Programs
Reading: Thompson Ch.8
Clauses in a function denition specify computations.
They can also be used as mathematical properties.
Symbolic execution can be used to show ge
Fractals and procedural terrain
Fractals are naturally recursive shapes they are dened by rules that
Graphics Package Application:
Fractals
specify how to make the shape from smaller and simpler copies of itself.
Fractals are widely used in computer anima
Graphics.Gloss
The Graphics.Gloss graphics package was developed here at ANU
Algebraic Data Types Case Study:
A Graphics Package
COMP1100 Introduction to Programming and Algorithms
(formerly known as ANUPlot).
It provides relatively simple access to 2D g
Department of Computer Science, Australian National University
COMP1100 Introduction to Programming and Algorithms
Semester 1, 2010
Week 3 Practical Class Exercises
Dening Simple Functions in Haskell
Objectives
The aim of this class is to help you learn t
Department of Computer Science, Australian National University
COMP1100 Introduction to Programming and Algorithms
Semester 1, 2010
Week 4 Practical Class Exercises
Developing Programs in Haskell
Objectives
The aim of this class is to help you learn more
Department of Computer Science, Australian National University
COMP1100 Introduction to Programming and Algorithms
Semester 1, 2010
Week 5 Practical Class Exercises
Recursive Functions on Lists
Objectives
The aim of these exercises is to give you more pra

Here we define the cells, which in our case we represent with colours.
You don't really need to care about anything after getStateColour
But if you're feeling brave, feel free to read on
Robert 'Probie' Offner
Feb 2016
module Datastructures.Cells where
cfw_# Language MultiParamTypeClasses #
 Here we define an Ant. An Ant is just a position, a direction
 and a transition system
 Robert 'Probie' Offner
 Feb 2016
module Datastructures.Ant where
import Internals.AntLike
import Datastructures.Cells
imp
# COMP1100/1130 Assignment 1: Langton's Ant
![](screenshots/langtonSquare/LLRR.gif)
# What is this?

A collection of dots?
My notes after listening to Tony?
An artistic rendering of an alien space ship?
Cat videos?
Ok, seriously, what is this? Well, you
data Color = Black  White
deriving (Read, Show, Enum, Eq, Ord)
putCell c = putStr (case c of Black > "#"
White > ".")
toggle : Color > Color
toggle color = toEnum $ 1  fromEnum color
data Dir = East  North  West  South
deriving (Read, Show, Enum,
Yet Another Haskell Tutorial
Hal Daume III
Copyright (c) Hal Daume III, 20022006. The preprint version of this tutorial is
intended to be free to the entire Haskell community, so we grant permission to copy
and distribute it for any purpose, provided tha
Introduction to Programming and Algorithms 2015
1
Introduction
Uwe R. Zimmer  The Australian National University
Introduction
References
Mathematica und verwandter Transactions of the American Mathematical Society
Systeme I (On Formally
1953 vol. 74 (2)
Introduction to Programming and Algorithms 2014
1
Introduction
Uwe R. Zimmer  The Australian National University
Introduction
References
Mathematica und verwandter Transactions of the American Mathematical Society
Systeme I (On Formally
1953 vol. 74 (2)
Introduction to Programming and Algorithms 2014
3
Essential Programming
Uwe R. Zimmer  The Australian National University
Essential Programming
References
[Thompson2011]
Thompson, Simon
Haskell  The craft of functional programming
Addison Wesley, third
Department of Computer Science, Australian National University
COMP1100 Introduction to Programming and Algorithms
Semester 1, 2010
Week 7 Practical Class Exercises
Supermarket Docket Example
Objectives
This weeks practical exercises are based on the Supe
Dening Functions Revisited:
Saying Numbers (again)
Saying Phone Numbers
How would we design a function to say phone numbers?
This should be easier we normally just say the digits in sequence.
COMP1100 Introduction to Programming and Algorithms
Clem Baker
If you think about the usual denition of length:
Accumulating Parameters
COMP1100 Introduction to Programming and Algorithms
length []
=0
length ( x : xs ) = 1 + length xs
it corresponds more to counting like this:
a : ( b : ( c : ( d : [])
Clem BakerFin
Computers, Programs, Programming Languages
What is a computer?
COMP1100 Introduction to Programming and Algorithms
Clem BakerFinch
Australian National University
Semester 1, 2010
COMP 1100 Computers, Programs, Programming Languages
1
COMP 1100 Computers,
What is this course about?
Introduction to the basic principles of programming
First part of a sequence COMP1100 + COMP1110
Welcome to
or COMP1100 + ENGN2219 for Engineers
About 85% programming concepts using Haskell,
COMP1100 Introduction to Programmi
T H E AUSTRALIAN NATIONAL UNIVERSITY
First Semester 2009
COMP1100
Introduction Programming and Algorithms
COMP1130
Data Structures and Algorithms 1
Writing Period: 3 hours duration
Study Period: 15 minutes duration
Permitted Materials: No restrictions, ot
ENGN1211 Discovering Engineering
Tutorial #4
CAD
Aim
Ideally, you will have attempted the CAD tutorial exercises prior to coming to the tutorial
session, in order to make use of this time to ask questions on aspects you found
challenging.
Preparation
If p
Department of Computer Science, Australian National University
COMP1100 Introduction to Programming and Algorithms
Semester 2, 2010
Week 12 Practical Class Exercises
Lists in Java
Objectives
The aim of these exercises is to give you some practice using li