| Higher-order Function |
Article Index for Higher-order |
Website Links For Function |
Information AboutHigher-order Function |
| CATEGORIES ABOUT HIGHER-ORDER FUNCTION | |
| functional programming | |
| lambda calculus | |
In mathematics these are also known as Operators or Functional s. The Derivative in Calculus is a common example, since it maps a function to another function. In the Untyped Lambda Calculus , all functions are higher-order; in a Typed Lambda Calculus , from which most Functional Programming Language s are derived, higher-order functions are generally those with types containing more than one arrow. In functional programming, higher-order functions that return other functions are said to be Curried . The map function found in many functional programming languages is one example of a higher-order function. It takes a function f as an argument, and returns a new function which takes a list and applies the f to each element.Other examples of higher-order functions include Function Composition , Integration , and the constant-function function λ''x''.λ''y''.''x''. ALTERNATIVES Programming languages can achieve some of the same algorithmic results as are obtained through higher-order functions by dynamically executing code (sometimes called "Eval" or "Execute" operations) in the scope of evaluation. Unfortunately, there are significant drawbacks to this approach:
Macros can also be used to achieve some of the effects of higher order functions. However, macros usually cannot avoid the problem of variable capture; they may also result in large amounts of duplicated code, which can be more difficult for a compiler to optimize. Macros are generally not strongly typed, although they may produce strongly typed code. Objects in an Object-oriented Programming environment can be used as higher order functions – a method of an object acts in many ways like a function, and a method may take objects (containing methods) as arguments or return objects with methods. Unfortunately, objects often carry additional run-time overhead compared to pure functions. Language syntax can introduce additional difficulties; an object must be created to hold any parameters that are functions, and any resulting function must also have an associated object. SEE ALSO |
|
|