English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Return a list containing the copies of Elem repeated N times.
duplicate(N, Elem)
N −The number of times the element needs to be repeated in the list.
Elem −The element that needs to be repeated in the list.
Return a new list with the element repeated N times.
-module(helloworld). -import(lists,[duplicate/2]). -export([start/0]). start() -> Lst1 = duplicate(5,1, io:fwrite("~w~n",[Lst1]).
When we run the above program, we will get the following results.
[1,1,1,1,1]