Functional Programming & Proofs


Trees and languages

  1. (map2)
    How to compose two streams having the same size with a function/operator g ?
let rec map2 o s1 s2 = 
  match s1,s2 with
  | End       ,End        -> End
  | Add(v1,s3),Add(v2,s4) -> Add(o v1 v2, map2 o s3 s4)
  | _         ,_ -> error "Streams must have the same size !";;

map2 (+) s s;;

9 - 10