Erlang – last

Erlang last

In this guide, we will discuss Erlang last. Returns the last element of the list.

Syntax

last(lst1)

Parameters

  • Lst1 − The list of elements.

Return Value

Returns the last element of the list.

For example

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

start() -> 
   Lst1=[1,2,3,4], 
   io:fwrite("~w~n",[last(Lst1)]).

Output

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

4

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply