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
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"]
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"]
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)
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