exlist v0.1.0 Exlist.Lists
Extension to lists functions
Summary
Functions
adds the given element elem
to the end of the list list
adds the list to end of the given list as a list or list of items based on the boolean true
or false
respectively
Flattens the given list
and returns the sum
of those elements
Returns the given number
of elements in the list
adds the given element elem
to the begining of the list list
adds the list to begining of the given list as a list or list of items
based on the boolean true
or false
respectively
Functions
Specs
append(list, any) :: list
adds the given element elem
to the end of the list list
Examples
iex> Exlist.Lists.append []
nil
iex> Exlist.Lists.append [1,2,3],4
[1,2,3,4]
iex> Exlist.Lists.append [1,2,3],:atom
[1,2,3, :atom]
iex> Exlist.Lists.append [1,2,3],%{name: "john"}
[1, 2, 3, %{name: "john"}]
Specs
append(list, list, boolean) :: list
adds the list to end of the given list as a list or list of items based on the boolean true
or false
respectively
Examples
iex> Exlist.Lists.append [1,2,3],[4,5,6]
[1,2,3,[4,5,6]]
iex> Exlist.Lists.append [1,2,3],[4,5,6],:false
[1,2,3,[4,5,6]]
iex> Exlist.Lists.append [1,2,3],[4,5,6], :true
[1,2,3,4,5,6]
Specs
flat_sum([number]) :: number
Flattens the given list
and returns the sum
of those elements
Examples
iex> Exlist.Lists.flat_sum [1,2,3,4,[5,6,7,[8,9,0]]]
45
Specs
list_get(list, integer) :: list
Returns the given number
of elements in the list
Specs
prepend(list, any) :: list
adds the given element elem
to the begining of the list list
Examples
iex> Exlist.Lists.prepend []
nil
iex> Exlist.Lists.prepend [1,2,3],4
[4,1,2,3]
iex> Exlist.Lists.prepend [1,2,3],:atom
[:atom,1,2,3]
iex> Exlist.Lists.prepend [1,2,3],%{name: "john"}
[%{name: "john"},1, 2, 3]
Specs
prepend(list, list, boolean) :: list
adds the list to begining of the given list as a list or list of items
based on the boolean true
or false
respectively
Examples
iex> Exlist.Lists.prepend [1,2,3],[4,5,6]
[[4,5,6],1,2,3]
iex> Exlist.Lists.prepend [1,2,3],[4,5,6],:false
[[4,5,6],1,2,3]
iex> Exlist.Lists.prepend [1,2,3],[4,5,6], :true
[4,5,6,1,2,3]