Advanced Functional Prog.


Packages' Builder

D. Maps

  1. A map can be viewed as an key-value' list as illustrated below. Knowing this, propose a program that returns the value of a key in a map (:we will suppose that the key is in the "domain" of the map).
let weights = 
  [(1,0.3);
   (2,0.7);
   (3,0.4);
   (4,0.5)];;
  1. Propose a program that returns the sets of keys (aka the "domain") from a map,
    ie. let products = keys weights;; // = 1<>4

answers