Sha256: f97e92ece6d58dba3ccafe93e058f555789aa471591d800729c27413d01caa4c

Contents?: true

Size: 516 Bytes

Versions: 2

Compression:

Stored size: 516 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

  # silly accessors
  def second 	; self[1]	; end
  def third  	; self[2]	; end
  def fourth 	; self[3]	; end
  def fifth  	; self[4]	; end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
muflax-0.3.6 lib/muflax/array.rb
muflax-0.3.5 lib/muflax/array.rb