blog

Home / DeveloperSection / Blogs / Higher Order Function in Erlang.

Higher Order Function in Erlang.

Sunil Singh 2772 17-Jun-2015

In mathematics and computer science, a higher-order function (also functional form, functional or functor) is a function that does at least one of the following: takes one or more functions as an input. 

An important part of all functional programming languages is the ability to take a function you defined and then pass it as a parameter to another function. This, in turn, binds that function parameter to a variable which can be used like any other variable within the function.

 A function that can accept other functions transported around that way is named a higher order function. Higher-order functions are a powerful means of abstraction and one of the best tools to master in Erlang.

For example-

-module(functions).
-export([add/2,one/0,two/0]).
one() -> 1.
two() -> 2.
add(X,Y) -> X() + Y().
functions:add(fun functions:one/0,fun functions:two/0). // function call

output=3.


Updated 24-Feb-2018

Leave Comment

Comments

Liked By