COMP1100 PAL
How do you Haskell?
1
Intro
Welcome to your first PAL! Work on this worksheet in groups on the whiteboard, and assign your
group a scribe that will write your answers on the board, Change your scribe every few minutes
so everyone can get a tu
Time and space behavior
Chapter 20
Algorithmic complexity
How many steps does it take to execute an algorithm
given an input of size n?
Complexity of functions
Consider:
f n = 2 n2 + 4 n + 13
This function has three components:
a constant, 13
a term 4 n
Abstract Data Types
(continued)
Chapter 16 of Thompson
Search Trees
A binary search tree is a binary tree whose elements are ordered.
Recall:
data Tree a = Nil | Node a (Tree a) (Tree a)
A tree (Node val t1 t2) is ordered if:
all values in t1 are smaller
Abstract Data Types
Chapter 16 of Thompson
Information Hiding
Abstract data types (ADTs) allow
information hiding on types.
They hide the representation (or
model) behind an abstract set of
operations.
Separates:
data type definition from
representat
Lazy Evaluation in Haskell
Chapter 17 of Thompson
Lazy evaluation
A function will only evaluate an argument if its value is actually needed.
For structured arguments only those parts needed are evaluated.
For example, intermediate lists are not necessaril
Time and space behavior
Chapter 20 (continued from 1130)
Space behaviour: lazy evaluation
Rule of thumb for space is the size of the largest expression produced
during evaluation.
This is accurate for computing numbers or Booleans, but not for data
stru
Games
Minimax for 2-player games
Minimax is a standard AI strategy for 2-player games that are
alternating: players take turns
deterministic: each move has a well-defined outcome (there is no randomness)
perfect-information: each player knows the complete
Basic types and definitions
Chapter 3 of Thompson
Booleans [named after logician George Boole]
Boolean values True and False are the result of tests
are two numbers equal
is one smaller than the other
The Haskell type is called Bool.
The language predef
COMP1100 PAL
Building Enigma
1
Introduction
During the Second World War, the German military employed the use of a machine called Enigma
to encode their radio messages before sending them. This allowed them to transmit their messages
in the open without w
COMP1100 PAL
Lists, Recursion and Code Reuse
1
Lists and Recursion
Lists are an ordered set of elements of the same data type. Consider some of these examples.
A list of type Int: [1, 2, 3, 4, 5, 9, 25, 167, 3, 2, 1].
A list of type Char: [g, r, o, o, v
16/02/2016
programming constructs,
variables, loops, conditions
recursion
se
ar
m ch
ac
hi
ne
le
pr dy arn
og na in
ra m g
m ic
m
in
g
comp1030 vs comp1100?
comp1030
types
write efficient code
comp1100 practical development experience
1
other differences:
COMP1100 PAL
Lists and Recursion
1
Introduction
Welcome back to PAL!
This week were going to be looking at using recursion in our Haskell functions. In particular we
will be looking at how to break down certain recursive and enumerative data-types.
You wi
Counselling services at the ANU
http:/counselling.anu.edu.au
Announcements
1. Reminder: your lab this week is a 5-minute assessment exercise,
intended to give you (and us) feedback on your progress so far.
2. Assignment 1 is now out and you should begin
26/02/2016
CECS Class Representatives
Roles and Responsibilities
Be creative and proactive in gathering feedback (positive and negative) from your class mates about the
course.
Keep the following in mind:
* Confidentiality of your class mates persona
COMP1130 Lambda-Calculus
PAL
March 9, 2016
1
Introduction
Lambda Calculus is a Turing complete system, which essentially means that
any computation you can do with a computer/another programming language, you could also do using lambda calculus. That is q
WIRING UP WIRE WORLD
First assignment for Introduction to Programming and Algorithms 2015
Uwe R. Zimmer based on work by Robert Offner (Probie)
What are you looking at on the right?
A seven segment display showing the number
?
A picture of a seven seg