Earlier quoted context omitted.
> The implementation isn't even that horrible You're making me blush! The list of integers could be replaced by using tuples and reading their lengths to do basic arithmetic. Might run into recursion limits though.
> The list of integers could be replaced by using tuples and reading their lengths to do basic arithmetic. Is that anything like church encoding? https://www.wikiwand.com/en/Church_encoding#/Church_numerals
type two = [0, 0]
type three = [0, 0, 0]
type five = [...two, ...three]
type TupleToNumber = T[“length”]
const num: TupleToNumber = 5