module Klam::Primitives::Arithmetic
Public Instance Methods
*(a, b)
click to toggle source
# File lib/klam/primitives/arithmetic.rb, line 12 def *(a, b) a * b end
+(a, b)
click to toggle source
# File lib/klam/primitives/arithmetic.rb, line 4 def +(a, b) a + b end
-(a, b)
click to toggle source
# File lib/klam/primitives/arithmetic.rb, line 8 def -(a, b) a - b end
/(a, b)
click to toggle source
# File lib/klam/primitives/arithmetic.rb, line 16 def /(a, b) # Kl does not make a distinction between integers and reals. Dividing # the integer 3 by the interger 2 must yield 1.5 rather than 1. We'd # like to keep things in integers as much as possible, so we coerce a # to a float only if integer division is not possible. if a.kind_of?(Integer) && b.kind_of?(Integer) && a.remainder(b) != 0 a = a.to_f end a / b end
<(a, b)
click to toggle source
# File lib/klam/primitives/arithmetic.rb, line 28 def <(a, b) a < b end
<=(a, b)
click to toggle source
# File lib/klam/primitives/arithmetic.rb, line 36 def <=(a, b) a <= b end
>(a, b)
click to toggle source
# File lib/klam/primitives/arithmetic.rb, line 32 def >(a, b) a > b end
>=(a, b)
click to toggle source
# File lib/klam/primitives/arithmetic.rb, line 40 def >=(a, b) a >= b end
number?(a)
click to toggle source
# File lib/klam/primitives/arithmetic.rb, line 44 def number?(a) a.kind_of?(Numeric) end