import { type AddDigit } from "https://deno.land/x/rimbu@0.13.5/typical/strnum.ts";
Given two string digits, this type returns a tuple of which the first element is the digit resulting from addition of the two digits, and the second element is a boolean indicating whether there was an overflow.
Examples
Example 1
Example 1
AddDigit<'1', '2'> => ['3', false]
AddDigit<'8', '4'> => ['2', true]
definition: D1 extends "0" ? [D2, false] : D2 extends "0" ? [D1, false] : [D1, D2] extends ? ["0", true] : [D1, D2] extends ? ["1", true] : [D1, D2] extends "1"[] ? ["2", false] : [D1, D2] extends ? ["2", true] : [D1, D2] extends SymTup<"1", "2"> ? ["3", false] : [D1, D2] extends SymTup<"4", "9"> | SymTup<"5", "8"> | SymTup<"6", "7"> ? ["3", true] : [D1, D2] extends SymTup<"1", "3"> | "2"[] ? ["4", false] : [D1, D2] extends SymTup<"5", "9"> | SymTup<"6", "8"> | "7"[] ? ["4", true] : [D1, D2] extends SymTup<"1", "4"> | SymTup<"2", "3"> ? ["5", false] : [D1, D2] extends SymTup<"6", "9"> | SymTup<"7", "8"> ? ["5", true] : [D1, D2] extends SymTup<"1", "5"> | SymTup<"2", "4"> | "3"[] ? ["6", false] : [D1, D2] extends SymTup<"7", "9"> | "8"[] ? ["6", true] : [D1, D2] extends SymTup<"1", "6"> | SymTup<"2", "5"> | SymTup<"3", "4"> ? ["7", false] : [D1, D2] extends SymTup<"8", "9"> ? ["7", true] : [D1, D2] extends ? ["8", false] : [D1, D2] extends "9"[] ? ["8", true] : [D1, D2] extends ? ["9", false] : never