Erlang - append



Returns a new list List3 which is made from the elements of List1 followed by the elements of List2.

Syntax

append(List1,List2)

Parameters

  • List1 − The first list of values.

  • List2 − The second list of values.

Return Value

Returns a new list List3 which is made from the elements of List1 followed by the elements of List2.

For example

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

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

Output

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

[1,2,3,4,5]
erlang_lists.htm
Advertisements