Class: Integer

Inherits:
Object show all
Defined in:
lib/raskell/integer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.emptyObject



2
3
4
# File 'lib/raskell/integer.rb', line 2

def self.empty
  0
end

Instance Method Details

#foldl(func, unit) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/raskell/integer.rb', line 6

def foldl(func, unit)
  i = 0
  while i <= self
    unit = func.(unit, i)
    i+=1
  end
  unit
end

#foldr(func, unit) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/raskell/integer.rb', line 15

def foldr(func, unit)
  i = self
  while i >= 0
    unit = func.(i, unit)
    i-=1
  end
  unit
end