module Enumerable(T)

Overview

The Enumerable mixin provides collection classes with several traversal, searching, filtering and querying methods.

Including types must provide an each method, which yields successive members of the collection.

For example:

class Three
  include Enumerable(Int32)

  def each(&)
    yield 1
    yield 2
    yield 3
  end
end

three = Three.new
three.to_a                # => [1, 2, 3]
three.select &.odd?       # => [1, 3]
three.all? { |x| x < 10 } # => true

Note that most search and filter methods traverse an Enumerable eagerly, producing an Array as the result. For a lazy alternative refer to the Iterator and Iterable modules.

Included Modules

Direct including types

Defined in:

numcry/accumulate.cr
numcry/correlate.cr
numcry/stats.cr

Instance Method Summary

Instance methods inherited from module Numcry::Accumulate::Ext(T)

accumulate(initial : U, &block : U, T -> U) forall U accumulate, cumprod cumprod, cumsum cumsum

Instance Method Detail

def corrcoef(other : Enumerable, ddof = 0.0) #

[View source]
def cov(other : Enumerable, ddof = 0.0) #

[View source]
def mean #

[View source]
def std(ddof = 0.0) #

[View source]
def var(ddof = 0.0) #

[View source]