Enum.take
You're seeing just the function
take
, go back to Enum module for more information.
Specs
Takes an amount
of elements from the beginning or the end of the enumerable
.
If a positive amount
is given, it takes the amount
elements from the
beginning of the enumerable
.
If a negative amount
is given, the amount
of elements will be taken from the end.
The enumerable
will be enumerated once to retrieve the proper index and
the remaining calculation is performed from the end.
If amount is 0
, it returns []
.
Examples
iex> Enum.take([1, 2, 3], 2)
[1, 2]
iex> Enum.take([1, 2, 3], 10)
[1, 2, 3]
iex> Enum.take([1, 2, 3], 0)
[]
iex> Enum.take([1, 2, 3], -1)
[3]