Slide 49
Slide 49 text
func i(x: T) -> T {
return x
}
func m(f: (T -> U), a: [T]) -> [U] {
return a.map(f)
}
func r(e: U, f: ((U, T) -> U), a: [T]) -> U {
return a.reduce(e, combine: f)
}
The expressiveness of types
???
25
* Guess the function! (Assuming no type inspection nor non-termination)
* Try this with tests.
* ”Theorems for free!” (aka parametricity)