COM SCI 131 Lecture 2:
Document Summary
# let cons(a,b) = a::b cons a * a list a list = # let cons a b = a :: b cons: a a list a list = # let abra = cons 37 abra: int list int list = e. g abra [12, 17] [37; 12; 17] e1 and also e2. This cons function is different in type to above. Want car to take a list whose first element is x, and the rest of the element is just _. Gives p1::p2 where p1 matches with the head and p2 matches with the rest of the list. When pattern matching completely fails at the runtime. Let rec ann l = match l with. | a::b 0 < a= && ann b. Functions can be anonymous e. g fun x cons x [] Functions often return other functions (by currying) (for other reasons) e. g ((f x) y) z.