Erlang - last


Advertisements

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
lists.htm
Advertisements