More Clojure Numeric Tests

Here are some more numeric tests.

I went through a Scheme tutorial titled “Teach Yourself Scheme in Fixnum Days”. One page had a nice code excerpt with functions showing all the different kinds of numbers that I found helpful.

  • The set of integers (like 42)
  • Are within the set of rational numbers (like 22/7)
  • Are within the set of real numbers (3.14)
  • Are within the set of complex numbers (like 2+3i)
  • Are within the set of all numbers.

Numbers in Clojure do not quite fit into this hierarchy, since Clojure runs on the JVM. Functions that test for real numbers (like float? or decimal?) return false for integers.

 

You’re welcome.