#!/usr/bin/env ruby # -*- encoding: utf-8 -*- # Copyright muflax , 2013 # License: GNU GPL 3 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