106 views4 pages
Verified Note
30 Oct 2018
School
Course
Professor

Document Summary

Templates are the core structure that we know a function must have, independent of the details of its implementation. In many cases the template for a function is determined by the type of data the function consumes. We refer to these as data driven templates. The recipe below can be used to produce a data driven template for any data type definition. For a given type typename the data driven template is: def fn_for_type_name(x: typename) -> : body. Where x is an appropriately chosen parameter name (often the initials of the type name) and the body is determined according to the table below. To use the table, start with the type of the parameter, i. e. typename, and select the row of the table that matches that type. The first row matches only primitive types, the later rows match parts of data type definitions.

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