Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
4 Cards in this Set
- Front
- Back
First-Class Function |
By “first-class” we mean that functions can be computed, passed, stored, etc. wherever other values can be computed, passed, stored, etc. |
|
Higher-Order Function |
The term higher-order function just refers to a function that takes or returns other functions. |
|
Generic Types (Parametic Polymorphism) |
This is called parametric polymorphism, or perhaps more commonly generic types. It lets functions take arguments of any type. It is a separate issue from first-class functions:
There are functions that take functions and do not have polymorphic types There are functions with polymorphic types that do not take functions. |
|
Anonymous Function |
fun triple_n_times (n,x) = n_times((fn y => 3*y), n, x) This code defines an anonymous function fn y => 3*y. It is a function that takes an argument y and has body 3*y. The fn is a keyword and => (not =) is also part of the syntax. We never gave the function a name (it is anonymous, see?), which is convenient because we did not need one. We just wanted to pass a function to n_times, and in the body of n_times, this function is bound tof. |