Sha256: c81927036f87fc1fc0e3dbafa9112135670f0760a69775341054e847a0cbe1a8

Contents?: true

Size: 606 Bytes

Versions: 7

Compression:

Stored size: 606 Bytes

Contents

# for Ruby 1.8 -> 1.9 transition
unless defined?(::Enumerator)
  begin
    require 'enumerator'
    Enumerator = Enumerable::Enumerator unless defined? ::Enumerator
  rescue LoadError # Ruby 1.9 already has it built-in.
  end
end

require 'facets/functor'

class Enumerator

  #
  def fx
    Functor.new(&method(:fx_send).to_proc)
  end

  private

  #
  def fx_send(op, *a, &b)
    map{ |e| e.send(op, *a, &b) }
  end

  ## TODO: When no longer needed to support 1.8.6 we can use:
  ##
  ## #
  ## def fx
  ##   Functor.new do |op, *a, &b|
  ##     map{ |e| e.send(op, *a, &b) }
  ##   end
  ## end

end

Version data entries

7 entries across 6 versions & 1 rubygems

Version Path
facets-2.9.3 lib/core/facets/enumerator/fx.rb
facets-2.9.2 lib/core/facets/enumerator/fx.rb
facets-2.9.2 src/core/facets/enumerator/fx.rb
facets-2.9.1 lib/core/facets/enumerator/fx.rb
facets-2.9.0 lib/core/facets/enumerator/fx.rb
facets-2.9.0.pre.2 lib/core/facets/enumerator/fx.rb
facets-2.9.0.pre.1 lib/core/facets/enumerator/fx.rb