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

append(list, elem)

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"}]
append(list1, list2, mode \\ false)

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]
flat_sum(list)

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
list_get(list, num)

Specs

list_get(list, integer) :: list

Returns the given number of elements in the list

prepend(list, elem)

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]
prepend(list1, list2, mode \\ false)

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]