Navigation
index
next
|
previous
|
YSC1212 2019
»
YSC1212 Lecture Notes, Week 08
ΒΆ
Polymorphic lists in OCaml
Resources
Lists
The “plural” naming convention
A sample of lists
The list constructor, in actuality
Constructing lists: the atoi function
Destructuring non-empty lists: list accessors
Prototypical skeleton of structurally recursive functions over lists
Unparsing polymorphic lists
The atoi function, revisited
About the nesting in the traces
Interlude
Unparsing polymorphic lists, refined
The atoi function, re2visited
Another interlude
Compound unparsing
Example: computing the length of a list
After hours
Destructuring lists conditionally: match expressions
Exercise 0
Prototypical skeleton of structurally recursive functions over lists, revisited
Example: unparsing polymorphic lists, revisited
Example: computing the length of a list, revisited
Example: computing the list of successive suffixes of a list
Exercise 1
Postlude
Resources
Version
Polymorphic lists in OCaml, continued
Resources
Example: copying a list
Example: concatenating two lists
Food for thought
Exercise 2
On the right associativity of list concatenation
Example: duplicating the elements of a list
Exercise 3
Resources
Version
The map function over polymorphic lists
Resources
Warmup #1: mapping the successor function
Warmup #2: mapping the predecessor function
Warmup #3: mapping the square function
Warmup #4: mapping the list-singleton function
Generalization: the map function for lists
Exercise 4
The logical counterpart of the map function for lists
The case of the last call in list_andmap and list_ormap
Resources
Version
Representing sets as lists
Resources
A practical consideration
Well-formed representation
Set membership
Set inclusion
Set equality
Adding an element to a set
Creating a random set
Set union
Exercise 4
Solution for Exercise 4
First interlude
Second interlude
Exercise 5
Set intersection
Exercise 6
Solution for Exercise 6
Exercise 7
Exercise 8
Set difference
Exercise 9
Solution for Exercise 9
Exercise 10
Exercise 11
Exercise 12
Normalizing a list into the representation of a set
Exercise 13
Solution for Exercise 13
Exercise 14
Solution for Exercise 14
Computing the Cartesian product of two sets
Computing the Cartesian product of three sets
Exercise 15
Computing the powerset of a set
Exercise 15
A reflective interlude
Solution for Exercise 15
Aftermath
Exercise 16
A pragmatic approach to solving Exercise 16
After hours
Resources
Version
Exercises
From the midterm project
Mandatory exercises
Recommended exercise
Exercise 17
Solution for Exercise 17
Version
Previous topic
Exercises
Next topic
Polymorphic lists in OCaml
Quick search
Enter search terms or a module, class or function name.
Navigation
index
next
|
previous
|
YSC1212 2019
»