Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/extensions.rb

Direct Known Subclasses

ConstraintSolver::ConstraintList

Instance Method Summary collapse

Instance Method Details

#eachAfter(element, &block) ⇒ Object



18
19
20
21
22
# File 'lib/extensions.rb', line 18

def eachAfter(element, &block)
	self[((self.index(element) or -1) + 1)..-1].each { |x|
 yield x
	}
end

#eachStartWith(element, &block) ⇒ Object



24
25
26
27
28
# File 'lib/extensions.rb', line 24

def eachStartWith(element, &block)
	self[(self.index(element) or 0)..-1].each { |x|
 yield x
	}
end

#foldLeft(function) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/extensions.rb', line 10

def foldLeft(function)
	if self.size == 1
 return self.first
	else
 return function.call(self.first, self.rest.foldLeft(function))
	end
end

#restObject



4
5
6
7
8
# File 'lib/extensions.rb', line 4

def rest
	retval = self.clone
	retval.shift
	return retval
end