What is functional programming
Http://www.zhihu.com/topic/19585411/hot
The nature of functional programming
Functions in functional programming the term does not refer to a function in a computer (actually a subroutine), but rather to a function in mathematics, the mapping of an independent variable. This means that the value of a function is determined only by the value of the function parameter, not by other states. For example, the sqrt (x) function calculates the square root of X, as long as x is not changed, and whenever the call is called, the value is constant.
In a functional language, a function can be defined anywhere, within a function or function, as a function's parameter and return value, and can be combined with a function.
Heart Court
Links: http://www.zhihu.com/question/28292740/answer/40336090
Source: Know
Copyright belongs to the author, please contact the author for authorization.
Example
function Makeenscapehandler (func, preprocess)
return function (num)
num = preprocess (num)
Func (NUM)
End
End
Local function plusonefunc (num)
Return num+1
End
Local Printplusone = Makeenscapehandler (print, Plusonefunc)
Printplusone (1)
LUA Functional Programming Demo