Erlang – sum

Erlang sum

In this guide, we will discuss erlang sum. Returns the sum of elements in the list.

Syntax

sum(lst)

Parameters

  • Lst − The list of elements.

Return Value

Returns the sum of elements in the list.

For example

-module(helloworld). 
-import(lists,[sum/1]). 
-export([start/0]). 

start() -> 
   Lst1 = [5,6,4], 
   io:fwrite("~p~n",[sum(Lst1)]).

Output

When we run the above program, we will get the following result.

15

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply