Sha256: 69e5b9ef1c43af6ea4f28d71682fca8e4fc409ea38d9e391ee3492c11e06cda0
Contents?: true
Size: 791 Bytes
Versions: 25
Compression:
Stored size: 791 Bytes
Contents
module Numbers private def sum monoid(->(a, b) { a + b }, 0) end def add(increment) -> (number) { number + increment } end def even remainder_is(2, 0) end def odd remainder_is(2, 1) end def divide(divisor) ->(dividend) { dividend / divisor } end def remainder_is(divisor, remainder) ->(dividend) { remainder(dividend, divisor) == remainder } end def remainder(dividend, divisor) dividend % divisor end def range_from(start) Sequence.new(enumerator_of(increment, start)) end def range(from, to) Sequence.new((from..to).lazy) end def increment ->(number) { number + 1 } end def mod(divisor) ->(number) { number % divisor } end def greater_than(right) ->(left) { left > right } end end
Version data entries
25 entries across 25 versions & 1 rubygems