Erlang – nthtail

Erlang nthtail

In this guide, we will discuss Erlang nthtail. Returns the Nth tail of the List, that is, the sublist of List starting at N+1 and continuing up to the end of the list

Syntax

nthtail(N, List)

Parameters

  • N − The nth position from the tail from which the elements need to be returned.
  • Lst − The list of elements.

Return Value

Returns the Nth tail of List, that is, the sublist of List starting at N+1 and continuing up to the end of the list.

For example

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

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

Output

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

[3]

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply