Polymorphic functions
. Functions can be invoked with arguments of different types
. Built in operators for indexing arrays, applying functions, and manipulating pointers are usually polymorphic
. Extend type expressions to include expressions with type variables
. Facilitate the implementation of algorithms that manipulate data structures (regardless of types of elements)
- Determine length of the list without knowing types of the elements
In some circumstances, it is useful to write a function that can accept any data type for one of its parameters. Polymorphic functions facilitate the implementation of algorithms that manipulate data structures (regardless of types of elements).
|