Arc Forumnew | comments | leaders | submitlogin
1 point by jmatt 6064 days ago | link | parent

I think a macro solves the problem where (is 0 0.0) returns nil. I think the reason they are not equal has something to do with precision and the representation of 0 versus 0.0.

  ;allows equivalent ints to be equal.
  ;i.e 0 = 0.0, 1 = 1.000000, etc.
  (mac == (a b)
        `(if (and (is (type ,a) 'int)
                   (is (type ,b) 'int))
               (is (+ ,a 0.0) (+ ,b 0.0))
               (is ,a ,b)))
produces

arc> (== 0 0.0)

t

arc> (== 123 123.00)

t

arc> (== "a" "a")

t

arc> (== "a" "b")

nil

arc> (== 1 9)

nil

arc> (== 1 1.00000001)

nil

Interesting quirk. Glad I know that (is a b) may not always work.