- (e1); (e2): Evaluate e1 first, evaluate e2 next. Then return teh value of e2. - Type of doubly linked lists: type dll = { value : int; mutable succ : dll option; mutable pred : dll option };; - Question: How do we make a doubly linked list with the elements [3; 4]? How to do this with rec? let dll3 = { value = 3; pred=None; succ=None };; let dll4 = { value = 4; pred=dll3; succ=None };; dll3.pred <- dll4;; let dll3 = { value = 3; pred=None; succ=dll4 } and dll4 = { value = 4; pred=dll3; succ=None };; let rec even x = even (x - 2) under some situations let rec even x = !odd (x - 1) under some situations and <== The and keyword allows us to define mutually recursive functions rec odd x = !even (x - 1) under some conditions. ==================== let rec even x = if (x == 0) then true else if (x == 1) then false else not (even (x - 1));; let rec odd x = if (x == 0) then false else if (x == 1) then true else not (odd (x - 1));; let rec even x = if (x == 0) then true else odd (x - 1) and odd x = if (x == 0) then false else even (x - 1);; =================== "Tying the Knot" let rec even x = if (x = 0) then true else if (x = 1) then false else not (even (x - 1));; let recursive_placeholder = ref fun x -> false let even x = if (x = 0) then true else if (x = 1) then false else not ((!recursive_placeholder) (x - 1));; recursive_placeholder := fun x -> even x recursive_placeholder := even ======================================================================================================================== Module - Header files, imports, exports - Packages, interfaces, classes, inheritance - Compilation units - Namespaces: Prevent name collisions C++ namespaces, Java packages - Abstraction: C++ / Java / Python class Code reuse: "Draw method for a button is the same as the draw method for a scroll bar = Draw method for widgets" Inheritance Syntactic organization into files (Header files, #use in the toplevel, input / include in Latex) - Module: "Functor"