Module Tally :: Class TallyNum
[hide private]
[frames] | no frames]

Class TallyNum

source code

A single "zero agnostic" number, as represented in khipu.

TallyNum is only used during 'slow' tally processing. To avoid breaking commutivity, each 'digit' can exceed 10; a separate step is required to 'reduce' the carries in order to perform comparisons with other TallyNum objects.



Instance Methods [hide private]
 
__init__(self, arg)
The lstval field is a little-endian list of 'digits', although carries are not performed so digits can be any positive integer.
source code
 
__repr__(self) source code
 
__str__(self) source code
 
__eq__(self, other) source code
 
__ne__(self, other) source code
 
__cmp__(self, other) source code
 
__hash__(self) source code
 
reduceCarry(self, limit=None)
Generator of ints representing carry-reduced values of this TallyNum.
source code
Method Details [hide private]

__init__(self, arg)
(Constructor)

source code 
The lstval field is a little-endian list of 'digits', although carries are not performed so digits can be any positive integer. The least-significant 'digit' is lstval[0].

reduceCarry(self, limit=None)

source code 
Generator of ints representing carry-reduced values of this TallyNum. If none of the 'digits' in this TallyNum are greater than nine, than this function generates a single int, which is the result of concatenating the reversed digits together. Otherwise, we iterate over the carry possibilities; for example: 1-10 generates both '110' and '20'.