Advanced Functional Prog.


Packages' Builder

The objective of the present work is to define an algorithm that groups products into packages whose total weight is inferior to a limit wmax ; this, to minimize transportation.

A. Preliminary questions

  1. What will be the result of iter (0,[]) (fun (x,xs)->(x+1,x::xs)) 10 with the following function ?
let rec iter state transition = function
  | 0 -> state
  | n -> transition (iter state transition (n-1));;
  1. What is the standard name of the preceding function ?
  2. By using the previous example, propose an operator that computes an interval,
    ie. min<>max=[min;min+1;...;max].

answers