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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access