Sha256: 04939fa31390be9e1f879611e3c020abe5b52d06882be14c8aa2c26d1e414889

Contents?: true

Size: 375 Bytes

Versions: 4

Compression:

Stored size: 375 Bytes

Contents

#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
# Copyright muflax <mail@muflax.com>, 2013
# License: GNU GPL 3 <http://www.gnu.org/copyleft/gpl.html>

class Array
  def triangle
    return to_enum(:triangle) unless block_given?

    self.each.with_index do |a, ai|
      self.each.with_index do |b, bi|
        next if bi < ai
        yield [a, b]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
muflax-0.3.3 lib/muflax/array.rb
muflax-0.3.2 lib/muflax/array.rb
muflax-0.3.1 lib/muflax/array.rb
muflax-0.3.0 lib/muflax/array.rb