Navigation
index
next
|
previous
|
YSC1212 2019
»
YSC1212 Lecture Notes, Week 11
ΒΆ
Mutable data in OCaml
References in OCaml
Constructing mutable values
Dereferencing mutable values
Mutating references
The imperative simulation of String.mapi in terms of String.map
Version
Sequencing in OCaml
Sequencing in retrospect
On the associativity of sequencing
Exercise 1
Solution for Exercise 1
Version
Exceptions in OCaml
Computing the head of a list all by ourselves
Computing the tail of a list all by ourselves
Computing list heads and tails using OCaml’s predefined functions
Division by 0
Another error case
Raising an exception in OCaml
Computing the head of a list using a predefined exception
Computing the tail of a list using a predefined exception
Our own error cases using a predefined exception
Resources
Version
Programming using exceptions
Resources
Catching exceptions in OCaml
Interlude
Declaring new exceptions in OCaml
Application: multiplying all the integers in a binary tree
Exercise 2
Application: testing whether a leaf satisfies a given predicate in a binary tree
Exercise 3
Exercise 4
Exercise 5
Resources
Version
Imperative lists
Resources
Warmup
Unparsing imperative lists
Circular lists
How to construct a circular list
Interlude
A generic unit-test function for circular lists
How to detect whether an imperative list is circular: the unit-test functions
How to detect whether an imperative list is circular: Take 0
How to detect whether an imperative list is circular: Take 1
How to detect whether an imperative list is circular: Take 2
How to compute the length of an imperative list
How to fold right over imperative lists
How to fold left over imperative lists
How to detect whether an imperative list is circular using fold-right
How to detect whether an imperative list is circular using fold-left
How to compute the length of an imperative list using fold-left
How to compute the length of an imperative list using fold-right
How to compute the length of an imperative list using an exception
How to concatenate two imperative lists
How to reverse an imperative list
How to map a function over an imperative list
Exercise 6
Exercise 7
Exercise 8
Resources
Version
Exercises
Mandatory exercises
Recommended exercises
More exercises
Exercise 9
Exercise 10
Version
Previous topic
Exercises
Next topic
Mutable data in OCaml
Quick search
Enter search terms or a module, class or function name.
Navigation
index
next
|
previous
|
YSC1212 2019
»