In this guide, we will discuss Erlang nth. Returns the Nth element of List.
Syntax
nth(N,List)
Parameters
- N − The nth value to return from the list.
- Lst − The list of elements.
Return Value
Returns the Nth element of List.
For example
-module(helloworld). -import(lists,[nth/2]). -export([start/0]). start() -> Lst1 = [1,2,3], io:fwrite("~p~n",[nth(2,Lst1)]).
Output
When we run the above program, we will get the following result.
2
Next Topic : Click Here
Pingback: Erlang - merge | Adglob Infosystem Pvt Ltd
Pingback: Erlang - Lists | Adglob Infosystem Pvt Ltd