www.erlang.org Open in urlscan Pro
35.156.224.161  Public Scan

Submitted URL: http://erlang.org/
Effective URL: https://www.erlang.org/
Submission: On July 16 via manual from DE — Scanned from SE

Form analysis 1 forms found in the DOM

GET https://duckduckgo.com/

<form class="d-flex" role="search" method="get" action="https://duckduckgo.com/">
  <input type="hidden" name="sites" value="erlang.org">
  <input class="form-control me-2" id="searchfield" name="q" type="search" placeholder="Search erlang.org" aria-label="Search">
  <button class="btn btn-outline-primary" type="submit">Search</button>
</form>

Text Content

 * Download
 * Documentation
 * Community
 * News
 * Blog
 * EEP
 * About

Search

PRACTICAL FUNCTIONAL PROGRAMMING
FOR A PARALLEL WORLD

Get Erlang/OTP 27

fact(0) -> 1;              %% Pattern matching for control-flow
fact(N) -> N * fact(N-1).  %% Recursion to create loops

> example:fact(10).        %% Interactive shell for fast iterations
3628800
> [{I, example:fact(I)} || I <- lists:seq(1,10)].
[{1, 1}, {2, 2}, {3, 6}, {4, 24}, {5, 120}, {6, 720},
 {7, 5040}, {8, 40320}, {9, 362880}, {10, 3628800}]


Functional programming

> Fruits = ["banana","monkey","jungle"].     %% Immutable variables
["banana","monkey","jungle"]
> lists:map(fun string:uppercase/1, Fruits). %% Map values using stdlib functions
["BANANA","MONKEY","JUNGLE"]
%% Fold over lists using custom functions
> lists:foldl(fun(Str, Cnt) -> string:length(Str) + Cnt end, 0, Fruits).
18



Higher-order functions

> Parent = self().                         %% Get own process id
<0.376.0>
> Child = spawn(fun() -> receive go -> Parent ! lists:seq(1,100) end end).
<0.930.0>
> Child ! go.                              %% Send message to child
go
> receive Reply -> Reply end.              %% Receive response from child
[1,2,3,4,5,6,7,8,9,10,11|...]


Lightweight processes

-spec even(list(integer())) -> list(integer()).
even(Numbers) ->
  mapreduce(Numbers, fun(Number) -> Number rem 2 == 0 end).
mapreduce(Numbers, Function) ->
  Parent = self(),
  [spawn(fun() -> Parent ! {Number, Function(Number)} end) || Number <- Numbers],
  lists:flatten(
    [receive {Number, true} -> Number; _ -> [] end || Number <- Numbers]).


Parallel map-reduce to find even numbers

Previous Next

%% Return factorial for N
fact(0) -> 1;
fact(N) -> N * fact(N-1).

> example:fact(10).
3628800


Functional programming

> Fruits = ["banana","monkey"].
["banana","monkey"]
> lists:map(
    fun string:uppercase/1,
    Fruits).
["BANANA","MONKEY"]


Higher-order functions

> Me = self().
<0.376.0>        %% Send msg using !
> spawn(fun() -> Me!lists:seq(1,10) end).
<0.930.0>
> receive Reply -> Reply end.
[1,2,3,4,5,6,7,8,9,10]


Light-weight processes

-spec even(In) -> Out
  when In :: list(integer()),
       Out :: list(integer()).
even(Numbers) ->
  [Number || Number <- Numbers,
   Number rem 2 == 0].


Find even numbers

Previous Next

WHAT IS ERLANG?

Erlang is a programming language used to build massively scalable soft real-time
systems with requirements on high availability. Some of its uses are in
telecoms, banking, e-commerce, computer telephony and instant messaging.
Erlang's runtime system has built-in support for concurrency, distribution and
fault tolerance.

Erlang Quickstart

WHAT IS OTP?

OTP is set of Erlang libraries and design principles providing middle-ware to
develop these systems. It includes its own distributed database, applications to
interface towards other languages, debugging and release handling tools.

Getting Started with OTP

NEWS

ERLANG/OTP 27 HIGHLIGHTS

May 20, 2024 by Björn Gustavsson Erlang/OTP 27 is finally here. This blog post
will introduce the new features that we are most excited about.

ERLANG/OTP 27.0 RELEASE

May 15, 2024 by Björn Gustavsson Erlang/OTP 27 is a new major release with new
features, improvements as well as a few incompatibilities.

THE OPTIMIZATIONS IN ERLANG/OTP 27

April 23, 2024 by Björn Gustavsson This post explores the new optimizations for
record updates as well as some of the other improvements. It also gives a brief
historic overview of recent optimizations leading up to Erlang/OTP 27.

PARTICIPATE