删除列表的最后一个元素。该列表应为非空,否则该函数将因function_clause而出错。
droplast(List1)
List1 - 值列表。
返回删除了最后一个元素的新列表。
-module(helloLearnfk). -import(lists,[droplast/1]). -export([start/0]). start() -> Lst1=[1,2,3], Lst2=droplast(Lst1), io:fwrite("~w~n",[Lst2]).
当我们运行上面的程序时,我们将得到以下输出。
链接:https://www.learnfk.comhttps://www.learnfk.com/erlang/erlang-droplast.html
来源:LearnFk无涯教程网
[1,2]
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)