Functional Programming & Proofs

Revision (1)

Only few keywords to master: fun, let/rec/match and type.

Sample application

  1. How to define a Name or an Age with a type synonym ?
  2. How to define a Person having a Name and an Age with a type definition ?
  3. How to define a birthday function (using let and match) ?
  4. How to define a Group that can be either Empty or the Add of a Person to another group ?
  5. How to define an "happy new year" function that makes birthday of all the persons in a group ?
  6. How to generalize the concept of a group of person to a Collection of As (by using a generic) ?
  7. How to apply a function to all the element of a collection ? Then, how to make an "happy new year".
  8. How to transform a collection into a List ? Then, how to make an "happy new year".

answer

Go further

  1. By changing ages to marks, how to get persons having a mark upper or lower to 10 ? (see filter function)
  2. How to get the means of the marks ? See fold/reduce function and map-reduce technology.