Sha256: c513bbec588b446af36dd811dc7c18a5e322567248148ad8d6692faa71230ae4
Contents?: true
Size: 680 Bytes
Versions: 2
Compression:
Stored size: 680 Bytes
Contents
module Numbers def sum monoid(->(a, b) { a + b }, 0) end def add sum end def even remainder_is(2, 0) end def odd remainder_is(2, 1) 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(Enumerators::enumerator(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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
totally_lazy-0.1.16 | lib/numbers.rb |
totally_lazy-0.1.15 | lib/numbers.rb |