Crutches.Enum

Summary

many?(collection)

Shorthand for length(collection) > 1

without(collection, elements)

Returns a copy of the Enum without the specified elements

Types

b :: Boolean

a :: Any

l :: List

m :: Map

Functions

many?(collection)

Specs:

  • many?(m) :: b
  • many?(l) :: b

Shorthand for length(collection) > 1

Examples

iex> Enum.many?([])
false

iex> Enum.many?([nil, nil, nil])
true

iex> Enum.many?([1, 2, 3])
true

iex> Enum.many?(%{})
false

iex> Enum.many?(%{ name: "Kash" })
false

iex> Enum.many?([ answer: 42 ])
false
without(collection, elements)

Specs:

  • without(m, l) :: m
  • without(l, l) :: l

Returns a copy of the Enum without the specified elements.

Examples

iex> Enum.without(["David", "Rafael", "Aaron", "Todd"], ["Aaron", "Todd"])
["David", "Rafael"]

iex> Enum.without([1, 1, 2, 1, 4], [1, 2])
[4]

iex> Enum.without(%{ movie: "Inception", release: 2010 }, [:release])
%{ movie: "Inception" }

iex > Enum.without([ answer: 42 ], [:answer])
[]