CP114 Lecture Notes - Lecture 7: Mutation, Natural Number

45 views13 pages
25 Sep 2016
School
Course

Document Summary

Polymorphism: flexibility in the type of arguments; polymorphic function has contract with variables. 3. construction function (make-name etc) selector function (name-field etc) type predicate function (name? etc) Consumes a function and a list, and applies the function to each value in the list. 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) Produces a list of the values in the list that produces true when f is applied to it. Consumes a predicate function with one parameter, and a list. Produces the result of applying combine successively through the list, or base if list is empty. Consumes a function with 2 parameters (for example, + adds 2 values or more), a base, and a list. Consumes 2 parameters (build-list naturalnumber function); the function has one parameter. Creating a list of the first 10 even numbers, starting from 0.

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