CP114 Lecture Notes - Lecture 7: Mutation, Natural Number
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.