[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Paul Graham's PyCon Keynote



From: Michael Vanier <mvanier@cs.caltech.edu>
Subject: Re: Paul Graham's PyCon Keynote
Date: Thu, 10 Apr 2003 18:14:16 -0700

> >        but conceptually, we can say:
> >          data Integer = 0 | 1 | -1 | 2 | -2 | 3 | -3 | ...
> > 
> 
> Or:
> 
> data Integer = Zero | Successor Integer | Predecessor Integer
> 

Both of solutions are very inefficient, but there are ways to define
numbers in other way, which leads to system that humans use. It is
almost as simple (depending on base), it does have finite number of
constructors and it is efficient for computing with big nubers too:

data Integer = PositiveTerminator | NegativeTerminator |
               Zero Integer | One Integer | Two Integer |
               Three Integer | Four Integer | Five Integer |
               Six Integer | Seven Integer | Eight Integer |
               Nine Integer

so we can get base 10 numbers. We need to choose direction (from most
significant to least, or reverse):
so we can write 1234 as

One Two Three Four PositiveTerminator
or
Four Three Two One PositiveTerminator
depending on chosen direction.

Arithmetic can be defined in same way as humans do, compute digit by
digit.


Jakub Travnik
jabber://jtra@jabber.com