Advanced Functional Prog.

back - up - next


Course 4 - Summary

  1. Only 7 keywords: fun, let_rec, match_with, type_of
    Sample stack function:
let rec upStack s = 
  match s with
  | NewStack    -> NewStack
  | Push (v,s') -> Push (v+1,upStack s');;

upStack s;;

Generalization (map):

let rec mapStack f s = 
  match s with
  | NewStack    -> NewStack
  | Push (v,s') -> Push (f v,mapStack f s');;

mapStack ((+) 1) s;;

5