Funs: The Basic Unit of Abstraction

Erlang is a functional programming language. Among other things this means that functions can be used as arguments to functions and that functions can return functions. Functions that manipulate functions are called higher-order functions, and the data type that represents a function in Erlang is called a fun.

Higher-order functions are the very essence of functional programming languages—not only can functional programs manipulate regular data structures, they can also manipulate the functions that transform the data. Once you’ve learned to use them, you’ll love them. We’ll see a lot more of them in the future.

Funs can be used in the following ways:

  • To perform the same operation on every element of ...

Get Programming Erlang, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.