Tentative plan for 02157 Functional Programming (Autumn 2023)

Teacher: Michael R. Hansen.

Textbook: Functional Programming using F#, Michael R. Hansen and Hans Rischel, Cambridge University Press, 2013. (Abbreviated HR.)

Week Date Topic Read Exercises
35   1. Sept. Course introduction
Intro. to functional programming and F#
Lists (brief introduction)
HR 1, HR 2.1-2.6, HR 4.1-4.3 Installation of F# and first programs
See Material folder on DTU Learn
36   8. Sept. Functions, Basic types, Tuples and Lists
HR 2, HR 3.1-3.3, 3.5, 3.6
HR 4.1 - 4.4
  1. HR 1.5, HR 2.2, 2.8, HR 4.7
  2. Mini-project on polynomials: Part 1
    See Material folder on DTU Learn
37 15. Sept. Lecture slot: Recap of fundamental concepts
Selected old exam questions will be handed out (on Learn).
  • Should be solved using paper and pencil only
  • A TA will be available for answering questions
  • Solutions will be presented.
  1. HR 2.1, 4.3, 4.8, 4.9, 4.12
  2. Consider your solution to 4.7 and make an evaluation of 'multiplicity 2 [1; 2; 8; 2]'
  3. Exercise on polynomials: Part 2. You may also consider/start on Part 3
  4. Paper and pencil exercises: HR 4.16, 4.17
  5. Write F#-programs having the types (1) bool -> bool, (2) int -> int -> int, (3) 'a -> 'b -> 'a and (4) 'a -> ('a -> 'b) -> 'b
  6. Merge sort. A program to generate random lists is here
38 22. Sept. Programming as a model-based activity
Property-based testing - Briefly
HR 3.4-3.7, HR 4
  1. Paper and pencil exercises:
    • HR 4.18. Give an argument for the type of f.
    • Problem 2 from Summer Exam in 2015. You find some old exams here
  2. HR 4.11
  3. Exercise on polynomials: Part 3.
39 29. Sept. Disjoint union (Tagged values)
Higher-order list functions
HR 3.8-3.11, HR 5.1
  1. SimpleCompanyClub
  2. Week5.pdf
  3. Exercise on polynomials: Start on Part 5 (invariant checking).
    Properties concerning degrees should be considered next week.
40 6. Oct. Collections: Sets and Maps HR 5.2-5.3
  1. HR 5.3
  2. Make a revised version of the Cash register example in Section 4.6 where:
    1. The function findArticle is replaced by an application of List.tryFind
    2. The function makeBill is declared using List.foldBack
    You can find programs from the textbook here
  3. Solve last week's Luggage and Flight problem using functions from the List-library, whenever that is appropriate.
  4. Map coloring: validation of properties
  5. Polynomial exercise: Part 4. Thereafter, you can complete Part 5.
41 13. Oct. Modules HR 7
  1. Revise your solution of the simple company club problem (Week 39) using sets and maps whenever that is appropriate.
  2. Problem 1 from Exam, Fall 2013.
  3. Problem 1 from Exam, Fall 2015.
    Old exams can be found here
42 20. Oct. Autumn vacation
43 27. Oct. Finite trees (I)
Type inference shortly
HR 6
  1. Part 6 of exercise on polynomials
  2. Week8.pdf
44 3. Nov. Finite trees (II)
Functional and structural test shortly
HR 6
  1. File System
  2. Part 2 from Mini-project 2: Simple Compiler. See Material folder on DTU Learn.
  3. Thereafter you can continue with Part 1, Part 3 and Part 4 of Mini-project 2.
45 10. Nov. Tail recursion HR 9
  1. Week10.pdf
  2. You may complete the simple-compiler miniproject.
  3. You may start on the mini-project on propositional logic
46 17. Nov. Sequences

From 11:10 - 12:00: Functional Programming in the Wild
Guest lecture by Torben Hoffmann
VP, Business Unit Lead for Erlang Solutions London, a Trifork company
HR 11
  1. Summer exam 02157-2014, Problem 1(1,2,3) -- available here
  2. Fall exam 02157-2014, Problem 2(4,5) -- available here
  3. Week11.pdf
Continue with mini-project on propositional logic.
47 24. Nov. Verification: A short lecture
Work on old exam questions for Week 12 in the auditorium
-- uploaded to Material folder on Learn.
  • 11.1 and 11.9
  • CollatzConjecture.pdf
  • Week12.pdf
  • Summer exam 2014, Problem 1(4,5) -- available here
  • Fall exam 2014, Problem 2(1,2,3) -- available here
  • 48 1. Dec. From 10:15 - 12:00 in the auditorium
    1. Brief discussion of Course Evaluation
    2. Work on exam set from Fall 2016.
      See Material folder on Learn.
    A TA will be available in the auditorium from 10:15 - 12:00
    A solution will be uploaded to Learn.
    From 8:15 - 10:00 in the exercise class:
    • Work on exam set from Fall 2016. See Material folder on Learn.


    Michael R. Hansen, Nov. 29, 2023