nth
返回List的第N个元素。
语法 (Syntax)
nth(N,List)
参数 (Parameters)
N - 从列表返回的第n个值。
Lst - 元素列表。
返回值 (Return Value)
返回List的第N 个元素。
例如 (For example)
-module(helloworld).
-import(lists,[nth/2]).
-export([start/0]).
start() ->
Lst1 = [1,2,3],
io:fwrite("~p~n",[nth(2,Lst1)]).
输出 (Output)
当我们运行上述程序时,我们将得到以下结果。
2