Problem Solving
Abstraction
Solving problems
Chris is both the 7th fastest and 7th slowest athlete on her team. How
many total athletes are there on her team?
A. 12
B. 13
C. 14
D. 5
Which paycheck is
Currying and Uncurrying
Curried:
multiply : Int > Int > Int
multiply x y = x * y
Somewhat neater, permits partial evaluation, function application
extends: f x, f x y
Uncurrying bundles the argumen
Primitive recursion in practice
fun n
 n=0 =
 n>0 = fun (n1)
Powers of two
power2 : Integer > Integer
power2
 n=0 =
 n>0 = power2 (n1)
Powers of two
power2 : Integer > Integer
power2
 n=0
Defining functions over lists
(continued)
Chapter 7 of Thompson
Primitive recursion over lists
sumInts : [Integer] > Integer
sumInts []
= 0
 base case
sumInts (x:xs) = x + sumInts xs  inductive ca
Generalisation: Patterns of
computation
Chapter 10 of Thompson
Code reuse
The holy grail of programming languages is to maximize opportunities
to reuse code:
the same code can be used in different
WHEN?
Thursday 10th March
2016
5:30pm 6:30pm
WHERE?
CSIT Building
(#108)
Room N101
WHO?
ANU Graduates with the inside track on
making careers work!
 Ian Morrison Founder and Creative
Dire
17/02/2016
Problem: buying a computer
Computers have many different components
Use abstraction to understand essential properties
ABSTRACTION
I/O
CPU
USB
Core 1
Core 2
Cache
Printer
Monitor
Graphics
Verification and higher order
functions
Chapter 11
Functionlevel verification
Consider:
twice : (a > a) > (a > a)
twice f = (f . f)
 (twice.1)
This generalises as:
iter : Int > (a > a) > (a 
Higher order functions
Chapter 11 of Thompson
Higher order functions
In Haskell functions are themselves data that can be:
1. combined using operators
2. expressed as literal values (expressions) with
Department of Computer Science, Australian National University
COMP1100 Introduction to Programming and Algorithms
Semester 1, 2010
Week 7 Practical Class Exercises
Supermarket Docket Example
Objectiv
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
Object
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
Obje
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
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
Reasoning about programs
Chapter 9 of Thompson
Proof versus testing
A proof will state some property of a program that holds for all inputs.
Testing shows only that a property holds for a particular s
Algebraic Types (continued)
Chapter 14 of Thompson
Recursive algebraic types: trees
A tree is either nil (empty) or the joining of two subtrees into a tree node:
data NTree = NilT 
Node Integer NTree
Notes on Functional Programming with Haskell
H. Conrad Cunningham
[email protected]
Multiparadigm Software Architecture Group
Department of Computer and Information Science
University of Missi

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 'Pro
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
i
# 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 sh
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 = E
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
Introduction to Programming and Algorithms 2015
1
Introduction
Uwe R. Zimmer  The Australian National University
Introduction
References
Mathematica und verwandter Transactions of the American Mathem
Introduction to Programming and Algorithms 2014
1
Introduction
Uwe R. Zimmer  The Australian National University
Introduction
References
Mathematica und verwandter Transactions of the American Mathem
Introduction to Programming and Algorithms 2014
3
Essential Programming
Uwe R. Zimmer  The Australian National University
Essential Programming
References
[Thompson2011]
Thompson, Simon
Haskell  The
26/02/2016
What is a function?
Programming foundations
A recipe for generating outputs from inputs
multiply a number by itself
A set of (input, output) pairs:
(1,1) (2,4) (3,9) (4,16) (5,25)
An equ
COMP 1130 Lambda Calculus
based on slides by Jeff Foster, U Maryland
Motivation
Commonlyused programming languages are
large and complex
ANSI C99 standard: 538 pages
ANSI C+ standard: 714 pages
Java
Zaphod Beeblebrox
Trillian: You idiot! You signed the
order to destroy Earth!
Zaphod: I did?
Arthur: He did?
Trillian: Love and kisses Zaphod? You
didn't even read it, did you?
Zaphod: Well, I'm
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
Australi