3 ms·
Looks like the arithmetic only supports integers 0 through 10 https://github.com/ronami/meta-typing/blob/master/src/utils/math.d.ts https://github.com/ronami/m
by spencerchubb 3y ago
Looks like the arithmetic only supports integers 0 through 10
https://github.com/ronami/meta-typing/blob/master/src/utils/math.d.ts https://github.com/ronami/meta-typing/blob/master/src/utils/...
- mozey 3y ago"This project attempts to push TypeScript's type system to its limits by actually implementing various functions and algorithms, purely on top of the type system... Please note that this project is meant to be used for fun and learning purposes and not for practical use"
- spencerchubb 3y agoIt is indeed interesting! I was just trying to analyze it a bit deeper
- n_e 3y agoYou can count to an arbitrary number (until the recursion limit) by using tuples of length N (and go back and forth to number literals by using the type of tuple['length']) e.g. : type zero = [] type Inc<N extends string[]> = [...N,''] type Dec<N extends string[]> = N extends [...infer T,''] ? T : never type one = Inc<zero> type two = Inc<one> type oneb = Dec<two>
- dqbd 3y agoA tuple does have a upper limit of 10 000 elements, which means that with this approach we can count to 10 000 at most. Another approach which I tried is to do arithmetics on digits directly, storing digits in a tuple instead, but the code is not as elegant as the tuple one https://github.com/dqbd/ts-math-evaluate/blob/main/src/math/add.ts https://github.com/dqbd/ts-math-evaluate/blob/main/src/math/...
- vesinisa 3y agoNoticed the same. Not a very practical computer, although you could say the host CPU does the same except for int's in 0 through 2^64-1.