Erlang - sublist



Returns a sublist of elements.

Syntax

sublist(lst,len)

Parameters

  • Lst − The list of elements.

  • Len − The number of elements from which the sub list should be generated.

Return Value

Returns a sublist of elements.

For example

-module(helloworld). 
-import(lists,[sublist/2]). 
-export([start/0]). 

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

Output

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

[5,6]
erlang_lists.htm
Advertisements