English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Remove the last element from the List. The list must not be empty, otherwise the function will crash and produce a function_clause clause.
droplast(List1)
List1 −Value List.
Return a new list without the last element.
-module(helloworld). -import(lists,[droplast/1]). -export([start/0]). start() -> Lst1 = [1,2,3], Lst2 = droplast(Lst1), io:fwrite("~w~n",[Lst2]).
When we run the above program, we will get the following results.
[1,2]