Sha256: 3412bda35de2918619851bdf2ac52d4cf794a93f2fa38d415b0db7cf3dbaaed5

Contents?: true

Size: 605 Bytes

Versions: 20

Compression:

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

  def rfind *arg, &block
    i = self.rindex(*arg, &block)
    i.nil? ? nil : self[i]
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
muflax-0.5.1 lib/muflax/array.rb
muflax-0.5.0 lib/muflax/array.rb
muflax-0.4.2 lib/muflax/array.rb
muflax-0.4.1 lib/muflax/array.rb
muflax-0.4.0 lib/muflax/array.rb
muflax-0.3.23 lib/muflax/array.rb
muflax-0.3.22 lib/muflax/array.rb
muflax-0.3.21 lib/muflax/array.rb
muflax-0.3.20 lib/muflax/array.rb
muflax-0.3.19 lib/muflax/array.rb
muflax-0.3.18 lib/muflax/array.rb
muflax-0.3.17 lib/muflax/array.rb
muflax-0.3.16 lib/muflax/array.rb
muflax-0.3.14 lib/muflax/array.rb
muflax-0.3.13 lib/muflax/array.rb
muflax-0.3.12 lib/muflax/array.rb
muflax-0.3.11 lib/muflax/array.rb
muflax-0.3.10 lib/muflax/array.rb
muflax-0.3.9 lib/muflax/array.rb
muflax-0.3.8 lib/muflax/array.rb