Navigation
index
next
|
previous
|
Intro to CS 2023
»
Lecture Notes, Week 03
ΒΆ
Towards OCaml
An analogy about dynamic vs. static types
Binary relations – a reminder
Mathematical functions – a reminder
Total functions – a reminder
Partial functions – a reminder
Equivalence of functions / functional equality
Functions in Computer Science
Program equivalence, revisited
Postlude
Exercise 01
In a nutshell
Credit
Version
OCaml: a language of algebraic expressions, with names and functions
The toplevel loop
Comments
Integers
Booleans
Characters
Interlude
Strings
Interlude
Conditional expressions
Exercise 02
Type errors in OCaml
Pairs
Interlude
Exercise 03
Partial solution for Exercise 03
Interlude
Exercise 03, with more punctuation marks
Interlude
Tuples
Exercise 04
Interlude
The empty tuple
Exercise 05
Interlude – parentheses in OCaml
Exercise 06
Names and type environments
Exercise 07
Solution for Exercise 07
Interlude about environments and onion bulbs
Names and (value) environments
Predeclared names
Declaring a global name
Functions
Predeclared functions
Express interlude
Functions that return functions
Syntactic sugar for functions that return functions
Predeclared functions that return functions: integer addition
Another predeclared function that returns a function: integer subtraction
More predeclared functions that return functions
Interlude about errors
Even more predeclared functions that return functions
Interlude about errors
Interlude about corner cases
Exercise 08
Exercise 09
Analysis of Exercises 08 and 09
Artistic interlude
Ground equality
Functions as parameterized expressions (a post-rationalization)
Exercise 10
Solution for Exercise 10
A practical note about let-declarations
Exercise 11
Exercise 12
Exercise 13
Naming functions
Syntactic sugar for naming functions
Interlude
Functions as parameterized functions (a post-rationalization)
Syntactic sugar for naming functions that return functions
Food for thought
Functions that are applied to other functions
Version
Unit tests
Resources
Unit tests
Interlude about unit tests and the unit type
Unit tests for the factorial function
Unit tests for the fibonacci function
Exercise 14
Exercise 15
Exercise 16
Solution for Exercise 16, Version 1
Solution for Exercise 16, Version 2
Exercise 17
Exercise 18
Exercise 19
The glass is half empty
Interlude
The glass is not half full
Interlude
Exercise 20
Partial solution for Exercise 20
Exercise 21
Code coverage
Resources
Version
Using Emacs to interact with the OCaml processor
Requirements
What can go wrong
Perspectives
A concrete example
Last but not least
Version
Exercises for Week 03
Exercise 00
Resources
Mandatory exercises
Recommended exercises
Exercise 22
Solution for Exercise 22
Interlude
Resources
Version
Index of concepts for Week 03
Version
Previous topic
Index of concepts for Week 02
Next topic
Towards OCaml
Quick search
Enter search terms or a module, class or function name.
Navigation
index
next
|
previous
|
Intro to CS 2023
»