CS116 Chapter 2: Module 2

88 views6 pages

Document Summary

Module 2 not as simple to formulate a contract for map because map works for many types of functions. Example (map sqr list) (map not list) (map string-length los) Consumes (num -> num [>=0]) and (listof num) (boolean -> boolean) and (listof boolean) (string -> nat) and (listof string) Filter filter consumers a predicate and a list and produces a list. Foldr foldr consumes a function with 2 parameters, and a base be careful with the use of x and y represent types of values. Polymorphism flexibility in the type of arguments is called polymorphism a polymorphic function has a contract that has variables for the types concept not limited to scheme (but easier to implement in scheme than other languages) Things that have many faces means that x and y do not have to be atomic values: num, booleans, etc. they can be structures lists, and lists of lists a well.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents