module Elixir::Enum
Public Instance Methods
all?(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 5 def all? collection, &block collection.all? &block end
any?(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 9 def any? collection, &block collection.any? &block end
at(collection, index, default = nil)
click to toggle source
# File lib/elixir/enum.rb, line 13 def at collection, index, default = nil collection.first(index.next)[index] || default end
chunk(collection, n, step: nil, pad: nil)
click to toggle source
# File lib/elixir/enum.rb, line 17 def chunk collection, n, step: nil, pad: nil # TODO end
chunk_by(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 21 def chunk_by collection, &block collection.chunk(&block).map(&:last).to_a end
concat(*collections)
click to toggle source
# File lib/elixir/enum.rb, line 25 def concat *collections collections.inject :concat end
count(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 29 def count collection, &block collection.count &block end
drop(collection, count)
click to toggle source
# File lib/elixir/enum.rb, line 33 def drop collection, count collection.drop count end
drop_while(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 37 def drop_while collection, &block collection.drop_while &block end
each(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 41 def each collection, &block collection.each &block :ok end
empty?(collection)
click to toggle source
# File lib/elixir/enum.rb, line 47 def empty? collection collection.empty? end
fetch(collection, n)
click to toggle source
# File lib/elixir/enum.rb, line 51 def fetch collection, n # TODO end
fetch!(collection, n)
click to toggle source
# File lib/elixir/enum.rb, line 55 def fetch! collection, n # TODO end
filter(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 59 def filter collection, &block collection.select &block end
filter_map(collection, filter, mapper)
click to toggle source
# File lib/elixir/enum.rb, line 63 def filter_map collection, filter, mapper # TODO end
find(collection, ifnone = nil, &block)
click to toggle source
# File lib/elixir/enum.rb, line 67 def find collection, ifnone = nil, &block collection.find ifnone, &block end
find_index(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 71 def find_index collection, &block # TODO end
find_value(collection, ifnone = nil, &block)
click to toggle source
# File lib/elixir/enum.rb, line 75 def find_value collection, ifnone = nil, &block # TODO end
flat_map(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 79 def flat_map collection, &block collection.flat_map &block end
flat_map_reduce(collection, acc, &block)
click to toggle source
# File lib/elixir/enum.rb, line 83 def flat_map_reduce collection, acc, &block # TODO end
group_by(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 87 def group_by collection, &block collection.group_by(&block).map { |k, v| [k.to_s.to_sym, v] }.to_h end
intersperse(collection, element)
click to toggle source
# File lib/elixir/enum.rb, line 91 def intersperse collection, element collection.each_with_object(element).to_a.flatten 1 end
into(collection, list, transform = nil)
click to toggle source
# File lib/elixir/enum.rb, line 95 def into collection, list, transform = nil # TODO end
join(collection, joiner = '')
click to toggle source
# File lib/elixir/enum.rb, line 99 def join collection, joiner = '' collection.join joiner end
map(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 103 def map collection, &block collection.map &block end
map_join(collection, joiner = '', &block)
click to toggle source
# File lib/elixir/enum.rb, line 107 def map_join collection, joiner = '', &block collection.map(&block).join joiner end
map_reduce(collection, acc, &block)
click to toggle source
# File lib/elixir/enum.rb, line 111 def map_reduce collection, acc, &block # TODO end
max(collection)
click to toggle source
# File lib/elixir/enum.rb, line 115 def max collection collection.max or raise 'empty error' end
max_by(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 119 def max_by collection, &block collection.max_by &block end
member?(collection, value)
click to toggle source
# File lib/elixir/enum.rb, line 123 def member? collection, value collection.member? value end
min(collection)
click to toggle source
# File lib/elixir/enum.rb, line 127 def min collection collection.min or raise 'empty error' end
min_by(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 131 def min_by collection, &block collection.min_by &block end
partition(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 135 def partition collection, &block collection.partition &block end
reduce(collection, acc = nil, &block)
click to toggle source
# File lib/elixir/enum.rb, line 139 def reduce collection, acc = nil, &block collection.reduce acc, &block end
reject(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 143 def reject collection, &block collection.reject &block end
reverse(collection, tail = nil)
click to toggle source
# File lib/elixir/enum.rb, line 147 def reverse collection, tail = nil if tail collection.reverse << tail else collection.reverse end end
scan(collection, acc = 0, &block)
click to toggle source
# File lib/elixir/enum.rb, line 155 def scan collection, acc = 0, &block # TODO end
shuffle(collection)
click to toggle source
# File lib/elixir/enum.rb, line 159 def shuffle collection collection.shuffle end
slice(collection, x, count = nil)
click to toggle source
# File lib/elixir/enum.rb, line 163 def slice collection, x, count = nil # TODO end
sort(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 167 def sort collection, &block collection.sort &block end
sort_by(collection, mapper, sorter = nil)
click to toggle source
# File lib/elixir/enum.rb, line 171 def sort_by collection, mapper, sorter = nil # TODO end
split(collection, count)
click to toggle source
# File lib/elixir/enum.rb, line 175 def split collection, count # TODO end
split_while(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 179 def split_while collection, &block # TODO end
sum(collection)
click to toggle source
# File lib/elixir/enum.rb, line 183 def sum collection collection.inject :+ end
take(collection, count)
click to toggle source
# File lib/elixir/enum.rb, line 187 def take collection, count collection.take count end
take_every(collection, nth)
click to toggle source
# File lib/elixir/enum.rb, line 191 def take_every collection, nth collection.each_slice(nth).map &:first end
take_while(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 195 def take_while collection, &block # TODO end
to_list(collection)
click to toggle source
# File lib/elixir/enum.rb, line 199 def to_list collection collection.to_a end
uniq(collection, &block)
click to toggle source
# File lib/elixir/enum.rb, line 203 def uniq collection, &block collection.uniq &block end
with_index(collection)
click to toggle source
# File lib/elixir/enum.rb, line 207 def with_index collection collection.each_with_index.to_a end
zip(collection1, collection2)
click to toggle source
# File lib/elixir/enum.rb, line 211 def zip collection1, collection2 collection1.zip collection2 end