Panty v0.1.2 Panty.Collection

Collection utilities

Link to this section Summary

Functions

Remove all falsy values in collection

Returns the list dropping its last element

Get intersection from given lists

Remove all elements that match the pattern in a collection

Get index of a substring from a pattern

Link to this section Functions

Link to this function compact(collection)
compact([any()]) :: [any()]

Remove all falsy values in collection

Examples

iex> Collection.compact([1, 2, 3, nil, 4, nil, 5])
[1, 2, 3, 4, 5]
iex> Collection.compact(["hello", "hola", false, "bonjour"])
["hello", "hola", "bonjour"]
Link to this function initial(collection)
initial([any(), ...]) :: [any()]

Returns the list dropping its last element

Examples

iex> Collection.initial([1, 2, 3, 4])
[1, 2, 3]
Link to this function intersection(first, second)
intersection([any()], [any()]) :: [any()]

Get intersection from given lists.

Examples

iex> Collection.intersection([1, 2, 3, 4], [2, 3])
[2, 3]
iex> Collection.intersection(["index", "carousel", "header", "footer"], ["header", "footer"])
["header", "footer"]
Link to this function reject(collection, pattern)
reject([any()], any()) :: [any()]

Remove all elements that match the pattern in a collection

Examples

iex> Collection.reject([1, 2, 3, nil, 4, nil, 5], nil)
[1, 2, 3, 4, 5]
iex> Collection.reject(["morning", "afternoon", %{a: "noon"}, "night"], %{a: "noon"})
["morning", "afternoon", "night"]
Link to this function substring_index(pattern, substring)
substring_index(String.t(), String.t()) :: integer() | nil

Get index of a substring from a pattern.

Examples

iex> Collection.string_find_index("abcdef", "cde")
2
iex> Collection.string_find_index("{% sections 'header' %}", "{% endschema %}")
nil