Erlang - reverse


Advertisements


Reverses a list of elements.

Syntax

reverse(lst)

Parameters

  • Lst − The list of elements which needs to be reversed.

Return Value

Returns a Reversed list of elements.

For example

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

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

Output

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

[3,2,1]

erlang_lists.htm

Advertisements