COM SCI 131 Lecture 2:

68 views3 pages
3 Feb 2019
School
Professor

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.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents