This blog explores how to create a number system from the first principles starting with only zero and two functions succ() & pred(). The code examples are in Ruby.
Read this post on thegeekrising.blogspot.com