Numbering a tuple #
A walk is a tuple of darts, and a coin sequence is a tuple of coins. This module
numbers such a tuple the way a numeral works: the j-th entry contributes its
own number times the base to the j-th power. Reading an entry back is dividing
by that power and taking the remainder, which is what an algorithm does.
Main results #
Complexity.NumEnc.instPi— theNumEncinstance forFin n → αComplexity.NumEnc.digit_sum,Complexity.NumEnc.sum_digits— reading a digit, and reassembling a number from its digits
Digits #
The instance #
The number of the i-th entry of a tuple, or zero past its end.
Equations
- Complexity.NumEnc.encAt f i = if h : i < n then Complexity.NumEnc.enc (f ⟨i, h⟩) else 0