Erlang - delete



Deletes an element from the list and returns a new list.

Syntax

delete(element,List1)

Parameters

  • Element − the element to delete from the list.

  • List1 − The first list of values.

Return Value

Returns a new list with the element deleted.

For example

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

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

Output

When we run the above program we will get the following result.

[1,3]
erlang_lists.htm
Advertisements