
- Erlang Tutorial
- Erlang - Home
- Erlang - Overview
- Erlang - Environment
- Erlang - Basic Syntax
- Erlang - Shell
- Erlang - Data Types
- Erlang - Variables
- Erlang - Operators
- Erlang - Loops
- Erlang - Decision Making
- Erlang - Functions
- Erlang - Modules
- Erlang - Recursion
- Erlang - Numbers
- Erlang - Strings
- Erlang - Lists
- Erlang - File I/O
- Erlang - Atoms
- Erlang - Maps
- Erlang - Tuples
- Erlang - Records
- Erlang - Exceptions
- Erlang - Macros
- Erlang - Header Files
- Erlang - Preprocessors
- Erlang - Pattern Matching
- Erlang - Guards
- Erlang - BIFS
- Erlang - Binaries
- Erlang - Funs
- Erlang - Processes
- Erlang - Emails
- Erlang - Databases
- Erlang - Ports
- Erlang - Distributed Programming
- Erlang - OTP
- Erlang - Concurrency
- Erlang - Performance
- Erlang - Drivers
- Erlang - Web Programming
- Erlang Useful Resources
- Erlang - Quick Guide
- Erlang - Useful Resources
- Erlang - Discussion
Erlang - duplicate
Returns a list which contains N copies of the term Elem.
Syntax
duplicate(N,Elem)
Parameters
N − The number of times the element needs to be duplicated in the list.
Elem − The element which needs to be duplicated in the list.
Return Value
Returns a new list with the Element duplicated N times.
For example
-module(helloworld). -import(lists,[duplicate/2]). -export([start/0]). start() -> Lst1 = duplicate(5,1), io:fwrite("~w~n",[Lst1]).
Output
When we run the above program we will get the following result.
[1,1,1,1,1]
erlang_lists.htm
Advertisements