Erlang - sublist 方法

返回元素的子列表。

语法

sublist(lst,len)

参数

  • Lst − 元素列表。

  • len − 应生成子列表的元素数量。

返回值

返回元素的子列表。

例如

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

start() -> 
   Lst1=[5,6,4], 
   io:fwrite("~p~n",[sublist(Lst1,2)]).

输出

当我们运行上面的程序时,我们将得到以下结果。

[5,6]

❮ erlang_lists.html