![]() |
![]() |
|
![]() |
![]() |
Encyclopedia :
H :
HI :
HIG :
Higher-order function |
|
|
Higher-order functionIn mathematics and computer science, higher-order functions are functionss which do at least one of the below:In mathematics these are also known as operators and functionals. The derivative in calculus is a common example, since it maps a function to another function. Higher-order functions were studied in lambda calculus long before functional programming existed. Lambda calculus is a formalism which has influenced the design of several functional programming languages, especially the Haskell programming language. Higher order functions in Haskell concisely implement tremendous power. For example, the following Haskell functions contrast squaring a list with and without higher order functions and currying. -- without higher order functions
squareListNoHof [] = []
squareListNoHof (head:tail) = (head^2):(squareListNoHof tail)
In the above example, The above was an example of a higher-order function that takes in a function as an argument, but does not return a function of sorts as an output. However there are standard higher order functions that do, such as the -- with higher order functions
Composite x = (cos.log.sqrt) (3*x+2)
-- without higher order functions
CompositeNoHof x = cos (log (sqrt (3*x+2)))
The AlternativeProgramming languages can simulate higher-order functions by dynamically executing code (sometimes called "Eval" or "Execute" operations) in the scope of evaluation and support functions which inherit the caller's variable scope. This can simplify and ease learning of a language. However... See also: functional analysis, combinatory logic |
|
|
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License. |
|
| © 2008 Chamas Enterprises Inc. |