English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Erlang List nth Method

Erlang List

Returns the Nth element of the List

Syntax

nth(N,List)

Parameter

  • N −The nth value to be returned from the list

  • Lst −Element List

Return Value

Returns the Nth element of the ListCountElement

-module(helloworld). 
-import(lists,[nth/2]). 
-export([start/0]). 
start() -> 
   Lst1 = [1,2,3, 
   io:fwrite("~p~n",[nth(2,Lst1)]).

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

2

Erlang List