English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Erlang List droplast Method

Erlang List

Remove the last element from the List. The list must not be empty, otherwise the function will crash and produce a function_clause clause.

Syntax

droplast(List1)

Parameter

  • List1 −Value List.

Return Value

Return a new list without the last element.

For example

-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]

Erlang List