Erlang - nthtail



返回列表的第 N 個尾部,即從 N+1 開始到列表末尾的列表子集。

語法

nthtail(N, List)

引數

  • N − 從尾部開始返回元素的第 N 個位置。

  • Lst − 元素列表。

返回值

返回列表的第 N 個尾部,即從 N+1 開始到列表末尾的列表子集。

例如

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

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

輸出

執行上述程式後,將得到以下結果。

[3]
erlang_lists.htm
廣告
© . All rights reserved.