OSDN Git Service

Mostly done with addition and subtraction.
authorSimon Forman <sforman@hushmail.com>
Sat, 15 Oct 2022 04:01:18 +0000 (21:01 -0700)
committerSimon Forman <sforman@hushmail.com>
Sat, 15 Oct 2022 04:01:18 +0000 (21:01 -0700)
docs/notebooks/BigInts.ipynb
implementations/bigints.joy

index 2679892..5cfdfd9 100644 (file)
    "execution_count": 1,
    "id": "08a49b81",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "2147483648"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "1 31 << "
    ]
    "execution_count": 2,
    "id": "b34d58ef",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": []
-    }
-   ],
+   "outputs": [],
    "source": [
     "unit [base] swoncat inscribe"
    ]
    "execution_count": 3,
    "id": "35476eac",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": []
-    }
-   ],
+   "outputs": [],
    "source": [
     "[valid_digit [0 >] [base <] &&] inscribe"
    ]
    "execution_count": 4,
    "id": "02a48806",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "32 true 1232147483648 false"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "32 valid_digit 1232147483648 valid_digit"
    ]
    "execution_count": 5,
    "id": "03a8fe65",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": []
-    }
-   ],
+   "outputs": [],
    "source": [
     "clear"
    ]
    "execution_count": 6,
    "id": "3fc98ccd",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1797196498 5748904729"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "12345678901234567890 base divmod swap"
    ]
    "execution_count": 7,
    "id": "b838c4cb",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1797196498 1453937433 2"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "base divmod swap"
    ]
    "execution_count": 8,
    "id": "42c9d92d",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1797196498 1453937433 2 0"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "base divmod swap"
    ]
    "execution_count": 9,
    "id": "faaac9d6",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1312754386 1501085485 57659106 105448366 58"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "clear 1234567890123456789012345678901234567890\n",
     "\n",
    "execution_count": 10,
    "id": "2a613f36",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "[58 105448366 57659106 1501085485 1312754386]"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "clear [1234567890123456789012345678901234567890]\n",
     "\n",
    "id": "c89e6054",
    "metadata": {},
    "source": [
-    "#### `to_bigint`"
+    "#### `to-bigint`"
    ]
   },
   {
     }
    ],
    "source": [
-    "[to_bigint [!-] [abs digitalize] cleave cons] inscribe"
+    "[to-bigint [!-] [abs digitalize] cleave cons] inscribe"
    ]
   },
   {
     }
    ],
    "source": [
-    "clear 1234567890123456789012345678901234567890 to_bigint"
+    "clear 1234567890123456789012345678901234567890 to-bigint"
    ]
   },
   {
     }
    ],
    "source": [
-    "clear -1234567890123456789012345678901234567890 to_bigint"
+    "clear -1234567890123456789012345678901234567890 to-bigint"
    ]
   },
   {
    "id": "7497680b",
    "metadata": {},
    "source": [
-    "#### `prep` and `from_bigint'`"
+    "#### `prep` and `from-bigint'`"
    ]
   },
   {
    ],
    "source": [
     "[prep rest 1 0 rolldown] inscribe\n",
-    "[from_bigint' [F] step popd] inscribe\n",
+    "[from-bigint' [F] step popd] inscribe\n",
     "[F [G] [H] clop popdd] inscribe\n",
     "[G popop base *] inscribe\n",
     "[H rolldown * +] inscribe"
    "source": [
     "clear 1 0 [1312754386 1501085485 57659106 105448366 58]\n",
     "\n",
-    "from_bigint'"
+    "from-bigint'"
    ]
   },
   {
     }
    ],
    "source": [
-    "to_bigint"
+    "to-bigint"
    ]
   },
   {
     }
    ],
    "source": [
-    "from_bigint'"
+    "from-bigint'"
    ]
   },
   {
     }
    ],
    "source": [
-    "to_bigint prep from_bigint'"
+    "to-bigint prep from-bigint'"
    ]
   },
   {
     }
    ],
    "source": [
-    "to_bigint prep from_bigint'"
+    "to-bigint prep from-bigint'"
    ]
   },
   {
     }
    ],
    "source": [
-    "to_bigint"
+    "to-bigint"
    ]
   },
   {
     }
    ],
    "source": [
-    "[first] [prep from_bigint'] cleave"
+    "[first] [prep from-bigint'] cleave"
    ]
   },
   {
    "source": [
     "This gives:\n",
     "\n",
-    "    foo == [first] [prep from_bigint'] cleave\n",
+    "    foo == [first] [prep from-bigint'] cleave\n",
     "    bar == swap [] [neg] branch\n",
-    "    from_bigint == foo bar"
+    "    from-bigint == foo bar"
    ]
   },
   {
    "id": "8bffedec",
    "metadata": {},
    "source": [
-    "#### `from_bigint`"
+    "#### `from-bigint`"
    ]
   },
   {
    ],
    "source": [
     "clear\n",
-    "[foo [first] [prep from_bigint'] cleave] inscribe\n",
+    "[foo [first] [prep from-bigint'] cleave] inscribe\n",
     "[bar swap [neg] [] branch] inscribe\n",
-    "[from_bigint foo bar] inscribe"
+    "[from-bigint foo bar] inscribe"
    ]
   },
   {
     }
    ],
    "source": [
-    "1234567890123456789012345678901234567890 to_bigint from_bigint"
+    "1234567890123456789012345678901234567890 to-bigint from-bigint"
    ]
   },
   {
     }
    ],
    "source": [
-    "neg to_bigint from_bigint"
+    "neg to-bigint from-bigint"
    ]
   },
   {
     "\n",
     "Let's figure out how to add two lists of digits (we will assume that the signs are the same.)  We need to put an inital `false` value for a carry flag, and then there's a `genrec`.\n",
     "\n",
-    "    initial-carry  false rollup\n",
+    "    initial-carry == false rollup\n",
     "      add-digits' ≡ [P] [THEN] [R0] [R1] genrec\n",
     "      \n",
     "       add-digits ≡ initial-carry add-digits'"
    "id": "223cee8e",
    "metadata": {},
    "source": [
-    "#### `bool_to_int`"
+    "#### `bool-to-int`"
    ]
   },
   {
    "source": [
     "clear\n",
     "\n",
-    "[bool_to_int [0] [1] branch] inscribe"
+    "[bool-to-int [0] [1] branch] inscribe"
    ]
   },
   {
     }
    ],
    "source": [
-    "false bool_to_int\n",
-    "true bool_to_int"
+    "false bool-to-int\n",
+    "true bool-to-int"
    ]
   },
   {
    "source": [
     "clear\n",
     "\n",
-    "false 1 2 [bool_to_int] dipd + +"
+    "false 1 2 [bool-to-int] dipd + +"
    ]
   },
   {
    "source": [
     "clear\n",
     "\n",
-    "true 1 2 [bool_to_int] dipd + +"
+    "true 1 2 [bool-to-int] dipd + +"
    ]
   },
   {
    "id": "89b971c9",
    "metadata": {},
    "source": [
-    "So the first part of `F` is `[bool_to_int] dipd + +` to get the total, then we need to do\n",
+    "So the first part of `F` is `[bool-to-int] dipd + +` to get the total, then we need to do\n",
     "\n",
     "`base mod` to get the new digit and `base >=` to get the new carry flag:"
    ]
    "source": [
     "Put it all together and we have:\n",
     "\n",
-    "    _add-with-carry0 ≡ [bool_to_int] dipd + +\n",
+    "    _add-with-carry0 ≡ [bool-to-int] dipd + +\n",
     "    _add-with-carry1 ≡ base [mod] [>=] clop\n",
     "\n",
     "    add-with-carry ≡ _add-with-carry0 _add-with-carry1\n"
    ],
    "source": [
     "clear\n",
-    "[_add-with-carry0 [bool_to_int] dipd + +] inscribe\n",
+    "[_add-with-carry0 [bool-to-int] dipd + +] inscribe\n",
     "[_add-with-carry1 base [mod] [>=] clop] inscribe\n",
     "[add-with-carry _add-with-carry0 _add-with-carry1] inscribe"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 91,
+   "execution_count": 57,
    "id": "b46a62ba",
    "metadata": {},
    "outputs": [
    "source": [
     "clear\n",
     "\n",
-    "123 to_bigint 456 to_bigint"
+    "123 to-bigint 456 to-bigint"
    ]
   },
   {
    "source": [
     "clear\n",
     "\n",
-    "123 to_bigint 456 to_bigint"
+    "123 to-bigint 456 to-bigint"
    ]
   },
   {
     }
    ],
    "source": [
-    "base -- to_bigint"
+    "base -- to-bigint"
    ]
   },
   {
   },
   {
    "cell_type": "code",
-   "execution_count": 95,
-   "id": "d8832fda",
+   "execution_count": 90,
+   "id": "dac1c858",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "markdown",
-   "id": "fdc6fc09",
+   "id": "184f6b2e",
    "metadata": {},
    "source": [
     "But this doesn't go quite far enough, I think.\n",
   },
   {
    "cell_type": "markdown",
-   "id": "94249f95",
+   "id": "7598e48c",
    "metadata": {},
    "source": [
     "I think `R0` will pretty much always do:\n",
   },
   {
    "cell_type": "markdown",
-   "id": "ecc190e3",
+   "id": "b721354e",
    "metadata": {},
    "source": [
     "And so it should be refactored further to something like:\n",
   },
   {
    "cell_type": "markdown",
-   "id": "c9fd7e21",
+   "id": "aa6e7586",
    "metadata": {},
    "source": [
     "Let's figure out the new form.\n",
   },
   {
    "cell_type": "markdown",
-   "id": "64118784",
+   "id": "0a5e4669",
    "metadata": {},
    "source": [
     "Let's not over think it.\n",
   },
   {
    "cell_type": "markdown",
-   "id": "90310271",
+   "id": "9d7aad63",
    "metadata": {},
    "source": [
     "With:\n",
   },
   {
    "cell_type": "code",
-   "execution_count": 93,
+   "execution_count": 91,
    "id": "55f64814",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 91,
+   "execution_count": 92,
    "id": "04e2d0d0",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 92,
+   "execution_count": 93,
    "id": "a28d9323",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "markdown",
-   "id": "e8433d46",
+   "id": "004b7aca",
    "metadata": {},
    "source": [
     "So to get from \n",
   },
   {
    "cell_type": "code",
-   "execution_count": 103,
-   "id": "77e6c03a",
+   "execution_count": 94,
+   "id": "bc16275c",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 104,
-   "id": "1119f1e6",
+   "execution_count": 95,
+   "id": "c517da7a",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 105,
+   "execution_count": 96,
    "id": "3f482224",
    "metadata": {},
    "outputs": [
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "02bfc247",
+   "id": "3a504505",
    "metadata": {},
    "outputs": [],
    "source": []
   },
   {
    "cell_type": "code",
-   "execution_count": 106,
+   "execution_count": 97,
    "id": "4b90e664",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "markdown",
-   "id": "089fc71c",
+   "id": "173bf5b7",
    "metadata": {},
    "source": [
     "Compare the above with what we wanted:\n",
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "929366cc",
+   "id": "c816fa4b",
    "metadata": {},
    "outputs": [],
    "source": []
   },
   {
    "cell_type": "code",
-   "execution_count": 107,
-   "id": "a3b7e48a",
+   "execution_count": 98,
+   "id": "ff88e2c1",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 108,
-   "id": "313ce113",
+   "execution_count": 99,
+   "id": "941a4426",
    "metadata": {
     "scrolled": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 110,
-   "id": "aca55d10",
+   "execution_count": 100,
+   "id": "917600dd",
    "metadata": {},
    "outputs": [
     {
    ]
   },
   {
-   "cell_type": "markdown",
-   "id": "92a471fa",
-   "metadata": {},
-   "source": [
-    "    combine-two-lists == build-two-list-combiner [i cons] genrec\n",
-    "    "
-   ]
-  },
-  {
    "cell_type": "code",
-   "execution_count": 111,
-   "id": "0fa2607d",
+   "execution_count": 101,
+   "id": "21f6b0e4",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 112,
-   "id": "026095a5",
+   "execution_count": 102,
+   "id": "4a8819fc",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 113,
-   "id": "15974737",
+   "execution_count": 103,
+   "id": "5d451c1e",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 114,
-   "id": "525bc382",
+   "execution_count": 104,
+   "id": "28fefe8a",
    "metadata": {},
    "outputs": [
     {
    "source": [
     "clear\n",
     "\n",
-    "123456 to_bigint\n",
+    "123456 to-bigint\n",
     "\n",
     "\n",
     "\n"
   },
   {
    "cell_type": "code",
-   "execution_count": 117,
+   "execution_count": 105,
    "id": "fa37c40c",
    "metadata": {},
    "outputs": [
    ]
   },
   {
-   "cell_type": "markdown",
-   "id": "5f739deb",
-   "metadata": {},
-   "source": [
-    "\n",
-    "    combine-two-lists == build-two-list-combiner [i cons] genrec\n",
-    "    \n",
-    "    build-two-list-combiner == [[[ditch-empty-list] swoncat] dip [pop] swoncat] dip [uncons-two] [dipd] sandwich [[ifte] ccons [P'] swons  [P] swap ] dip\n",
-    "    "
-   ]
-  },
-  {
    "cell_type": "code",
-   "execution_count": 118,
+   "execution_count": 106,
    "id": "850a1421",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 119,
-   "id": "52bb5921",
+   "execution_count": 107,
+   "id": "4b6005fc",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 120,
+   "execution_count": 108,
    "id": "c616033e",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 121,
+   "execution_count": 109,
    "id": "1a18ddd7",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 122,
+   "execution_count": 110,
    "id": "3c639487",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 123,
+   "execution_count": 111,
    "id": "c9222cab",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 124,
+   "execution_count": 112,
    "id": "f3bc8d28",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "markdown",
-   "id": "c85d6fe6",
+   "id": "82b7bf9a",
    "metadata": {},
    "source": [
     "#### Demonstrate `add-bigints`"
   },
   {
    "cell_type": "code",
-   "execution_count": 125,
-   "id": "3da6266b",
+   "execution_count": 113,
+   "id": "b4a71b70",
    "metadata": {},
    "outputs": [
     {
     }
    ],
    "source": [
-    "1234 999 [to_bigint] ii "
+    "1234 999 [to-bigint] ii "
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 126,
-   "id": "7d38dbaa",
+   "execution_count": 114,
+   "id": "6aba84ae",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 127,
-   "id": "e65f7ff9",
+   "execution_count": 115,
+   "id": "d5dc4dce",
    "metadata": {},
    "outputs": [
     {
     }
    ],
    "source": [
-    "from_bigint"
+    "from-bigint"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 128,
-   "id": "5d385f35",
+   "execution_count": 116,
+   "id": "2e9ab2c2",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": null,
-   "id": "fb7da91a",
+   "execution_count": 117,
+   "id": "080d81a3",
    "metadata": {},
-   "outputs": [],
-   "source": []
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": []
+    }
+   ],
+   "source": [
+    "clear"
+   ]
   },
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "679e9df6",
+   "id": "7b237ca8",
    "metadata": {},
    "outputs": [],
    "source": []
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "d4d2850a",
+   "id": "46f50f12",
    "metadata": {},
    "outputs": [],
    "source": []
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "c4da9da4",
+   "id": "7e035a2c",
    "metadata": {},
    "outputs": [],
    "source": []
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "55a37610",
+   "id": "f2492e55",
    "metadata": {},
    "outputs": [],
    "source": []
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "c637a7ea",
+   "id": "8dfddc89",
    "metadata": {},
    "outputs": [],
    "source": []
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "b56cf709",
+   "id": "7f2bf0e5",
    "metadata": {},
    "outputs": [],
    "source": []
   },
   {
    "cell_type": "code",
-   "execution_count": 112,
+   "execution_count": 118,
    "id": "9c50bd24",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 113,
+   "execution_count": 119,
    "id": "4c1dbabd",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 114,
+   "execution_count": 120,
    "id": "ef683ade",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 115,
+   "execution_count": 121,
    "id": "ff52920a",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 116,
+   "execution_count": 122,
    "id": "be946f53",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 117,
+   "execution_count": 123,
    "id": "056e3072",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 118,
+   "execution_count": 124,
    "id": "02d4e38e",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 119,
+   "execution_count": 125,
    "id": "5683eb84",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 120,
+   "execution_count": 126,
    "id": "a4e1f728",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 121,
+   "execution_count": 127,
    "id": "dc7c151a",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 122,
+   "execution_count": 128,
    "id": "50c2669a",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 123,
+   "execution_count": 129,
    "id": "1bbf3465",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 124,
+   "execution_count": 130,
    "id": "5a9347f6",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 125,
+   "execution_count": 131,
    "id": "69b18847",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 126,
+   "execution_count": 132,
    "id": "0b29370d",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 127,
+   "execution_count": 133,
    "id": "32ce148e",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 128,
+   "execution_count": 134,
    "id": "4efc8f76",
    "metadata": {},
    "outputs": [
     "\n",
     "we have three lists.  The first is a possibly-empty list of pairs to compare.\n",
     "\n",
-    "THe second two are the tails of the original lists.\n",
+    "The second two are the tails of the original lists.\n",
     "\n",
     "if the first list is non-empty then the second list must be empty so the whole function should return true\n",
     "\n",
   },
   {
    "cell_type": "code",
-   "execution_count": 129,
+   "execution_count": 135,
    "id": "7d973f7f",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 130,
+   "execution_count": 136,
    "id": "9239e0c4",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 131,
+   "execution_count": 137,
    "id": "0c58a6e0",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 132,
+   "execution_count": 138,
    "id": "7f302157",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 133,
+   "execution_count": 139,
    "id": "d25ef02e",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 134,
+   "execution_count": 140,
    "id": "06e0ffcb",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 135,
+   "execution_count": 141,
    "id": "b2428f49",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 136,
+   "execution_count": 142,
    "id": "4ef5f503",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 246,
+   "execution_count": 143,
    "id": "7f060f83",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 138,
+   "execution_count": 144,
    "id": "8d74a801",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 139,
+   "execution_count": 145,
    "id": "0104d2b0",
    "metadata": {},
    "outputs": [
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "false"
+      "true"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 140,
+   "execution_count": 146,
    "id": "4728d141",
    "metadata": {},
    "outputs": [
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "false"
+      "true"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 141,
+   "execution_count": 147,
    "id": "bfb5e62c",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 142,
+   "execution_count": 148,
    "id": "7983881c",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 143,
+   "execution_count": 149,
    "id": "677757c5",
    "metadata": {},
    "outputs": [
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "false"
+      "true"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 144,
+   "execution_count": 150,
    "id": "5691f813",
    "metadata": {},
    "outputs": [
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "false"
+      "true"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 145,
+   "execution_count": 151,
    "id": "b95fe984",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 146,
+   "execution_count": 152,
    "id": "b5ddac15",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 147,
+   "execution_count": 153,
    "id": "d4077376",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 148,
+   "execution_count": 154,
    "id": "ac840996",
    "metadata": {},
    "outputs": [
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "false"
+      "true"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 149,
+   "execution_count": 155,
    "id": "e7c3b141",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 150,
+   "execution_count": 156,
    "id": "95c7308d",
    "metadata": {},
    "outputs": [
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "true"
+      "false"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 151,
+   "execution_count": 157,
    "id": "5e43ba80",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 152,
+   "execution_count": 158,
    "id": "20070426",
    "metadata": {},
    "outputs": [
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "false"
+      "true"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 154,
+   "execution_count": 159,
    "id": "c97b0df9",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 155,
+   "execution_count": 160,
    "id": "980a1bbf",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 199,
+   "execution_count": 161,
    "id": "4f429421",
    "metadata": {},
    "outputs": [
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "false"
+      "true"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 158,
+   "execution_count": 162,
    "id": "5a6419ee",
    "metadata": {},
    "outputs": [
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "true"
+      "false"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 159,
+   "execution_count": 163,
    "id": "cd586291",
    "metadata": {},
    "outputs": [
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "false"
+      "true"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 160,
+   "execution_count": 164,
    "id": "35fb22d2",
    "metadata": {},
    "outputs": [
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "[3 2 1] [4 5 6]"
+      "[4 5 6] [3 2 1]"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 161,
+   "execution_count": 165,
    "id": "36d74e5b",
    "metadata": {},
    "outputs": [
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "[3 2 1] [4 5 6]"
+      "[4 5 6] [3 2 1]"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 202,
+   "execution_count": 166,
    "id": "dd645337",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 203,
+   "execution_count": 167,
    "id": "935552d4",
    "metadata": {},
    "outputs": [
   },
   {
    "cell_type": "code",
-   "execution_count": 204,
+   "execution_count": 168,
    "id": "05100765",
    "metadata": {},
    "outputs": [
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "true [3 2 1] [4 5 6]"
+      "false [4 5 6] [3 2 1]"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 134,
-   "id": "187c0381",
+   "execution_count": 169,
+   "id": "7ac873d4",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "markdown",
-   "id": "1a8a8196",
+   "id": "7ef0f655",
    "metadata": {},
    "source": [
     "### Subtraction, at last...\n",
   },
   {
    "cell_type": "markdown",
-   "id": "9751fd65",
+   "id": "173aa582",
    "metadata": {},
    "source": [
     "We want to use `check-gt` here:\n",
   },
   {
    "cell_type": "markdown",
-   "id": "df2ae839",
+   "id": "242e863f",
    "metadata": {},
    "source": [
     "It seems we should just flip the sign bit if we swap, eh?\n",
   },
   {
    "cell_type": "markdown",
-   "id": "c775c3a4",
+   "id": "37ed39c6",
    "metadata": {},
    "source": [
     "Now we subtract the digits:\n",
     "        [swap sub-carry]\n",
     "        [sub-with-carry]\n",
     "        build-two-list-combiner\n",
-    "        [i cons] genrec\n",
+    "        genrec\n",
     "\n",
     "We just need to define the pieces."
    ]
   },
   {
    "cell_type": "markdown",
-   "id": "32eeaf38",
+   "id": "844210e4",
    "metadata": {},
    "source": [
     "#### `sub-with-carry`\n",
   },
   {
    "cell_type": "markdown",
-   "id": "3b47df3b",
+   "id": "3c10e256",
    "metadata": {},
    "source": [
     "       carry a b sub-with-carry\n",
     "    ------------------------------\n",
     "         (a-b-carry)  new-carry\n",
     "\n",
-    "    _sub-with-carry0 ≡ [bool_to_int] dipd - -\n",
+    "    _sub-with-carry0 ≡ [bool-to-int] dipd - -\n",
     "    _sub-with-carry1 ≡ [base + base mod] [0 <] clop\n",
     "\n",
     "    sub-with-carry ≡ _sub-with-carry0 _sub-with-carry1\n"
   },
   {
    "cell_type": "code",
-   "execution_count": 135,
-   "id": "880dc3da",
+   "execution_count": 170,
+   "id": "c360cc7b",
    "metadata": {},
    "outputs": [
     {
     }
    ],
    "source": [
-    "[_sub-with-carry0 rolldown bool_to_int [-] ii] inscribe\n",
+    "[_sub-with-carry0 rolldown bool-to-int [-] ii] inscribe\n",
     "[_sub-with-carry1 [base + base mod] [0 <] cleave] inscribe\n",
     "[sub-with-carry _sub-with-carry0 _sub-with-carry1] inscribe"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 139,
-   "id": "bae53ad4",
+   "execution_count": 171,
+   "id": "3a84adff",
    "metadata": {
     "scrolled": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 140,
-   "id": "f54d93bc",
+   "execution_count": 172,
+   "id": "0dcdc968",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 141,
-   "id": "740034d8",
+   "execution_count": 173,
+   "id": "2d60492d",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "markdown",
-   "id": "d29e6193",
+   "id": "fc4ff7c6",
    "metadata": {},
    "source": [
     "That leaves the recursive branch:\n",
   },
   {
    "cell_type": "markdown",
-   "id": "d31868ab",
+   "id": "984f1bf4",
    "metadata": {},
    "source": [
     "    \n",
   },
   {
    "cell_type": "markdown",
-   "id": "5c4404a8",
+   "id": "845abba7",
    "metadata": {},
    "source": [
     "But there's a problem!  This winds up subtracting `a` from 0 rather than the other way around:\n",
   },
   {
    "cell_type": "code",
-   "execution_count": 147,
-   "id": "be093900",
+   "execution_count": 174,
+   "id": "20c8ad40",
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
-     "text": [
-      "[3 2 1]"
-     ]
+     "text": []
     }
    ],
    "source": [
   },
   {
    "cell_type": "markdown",
-   "id": "253538a4",
+   "id": "77e427f9",
    "metadata": {},
    "source": [
     "Try it out:"
   },
   {
    "cell_type": "code",
-   "execution_count": 148,
-   "id": "ce9f01e2",
+   "execution_count": 175,
+   "id": "92201303",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 160,
-   "id": "2120af39",
+   "execution_count": 176,
+   "id": "1a1d7cdc",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 161,
-   "id": "55fc1f59",
+   "execution_count": 177,
+   "id": "39ce9c6a",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 162,
-   "id": "1db3eaeb",
+   "execution_count": 178,
+   "id": "a93e916e",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 163,
-   "id": "ededec7b",
+   "execution_count": 179,
+   "id": "c2273ff3",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "markdown",
-   "id": "ffc08bef",
+   "id": "7c609313",
    "metadata": {},
    "source": [
     "But what about those leading zeroes?\n",
   },
   {
    "cell_type": "code",
-   "execution_count": 165,
-   "id": "fe557598",
+   "execution_count": 180,
+   "id": "d8c7f7a5",
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": null,
-   "id": "f7275cd6",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "740a5c97",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "9ea8ba1c",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 164,
-   "id": "b6c2e9ee",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": []
-    }
-   ],
-   "source": [
-    "[sub-carry-from-digits popd] inscribe"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "32cef119",
-   "metadata": {},
-   "source": [
-    "    sub-carry == pop"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 230,
-   "id": "c22775e9",
+   "execution_count": 181,
+   "id": "875aaafa",
    "metadata": {},
    "outputs": [
     {
     }
    ],
    "source": [
-    "[sub-like-bigints [uncons] dip rest check-gt sub-digits cons] inscribe\n",
-    "[sub-digits initial-carry sub-digits'] inscribe\n",
-    "[sub-digits'\n",
-    "    [sub-carry-from-digits]\n",
-    "    [swap sub-carry]\n",
-    "    [sub-with-carry]\n",
-    "    build-two-list-combiner\n",
-    "    \n",
+    "[sub-carry-from-digits\n",
+    "  [pop not]\n",
+    "  [popd]\n",
+    "  [_scfd_R0]\n",
+    "  [i cons-but-not-leading-zeroes]\n",
+    "  genrec\n",
     "] inscribe"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 231,
-   "id": "ac670030",
+   "execution_count": 182,
+   "id": "bd2447b6",
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
-     "text": [
-      "false [3 2 1] [6 5 4] [P] [[P'] [ditch-empty-list sub-carry-from-digits] [pop swap sub-carry] ifte] [uncons-two [sub-with-carry] dipd]"
-     ]
+     "text": []
     }
    ],
    "source": [
-    "clear\n",
-    "false\n",
-    "[3 2 1] [6 5 4]\n",
-    "[sub-carry-from-digits]\n",
-    "    [swap sub-carry]\n",
-    "    [sub-with-carry]\n",
-    "    build-two-list-combiner"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "8fbba815",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "[i cons] genrec\n"
+    "[_scfd_R0 uncons 0 swap [sub-with-carry] dip] inscribe"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": null,
-   "id": "cce0cc68",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "9163ad94",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "d862f5a8",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "976c4d53",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 212,
-   "id": "3b05693f",
+   "execution_count": 183,
+   "id": "ffaf1fcc",
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "[true 12345] [true 109]"
+      "[9]"
      ]
     }
    ],
    "source": [
     "clear\n",
-    "12345 to_bigint 109 to_bigint"
+    "\n",
+    "true [0 0 1] sub-carry-from-digits"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 213,
-   "id": "fc69485b",
+   "execution_count": 184,
+   "id": "8a2b2165",
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
-     "text": [
-      "false false [109] [12345] [P] [[[P'] [ditch-empty-list sub-carry-from-digits] [pop swap sub-carry] ifte] uncons-two [sub-with-carry] dipd]"
-     ]
+     "text": []
     }
    ],
    "source": [
-    "sub-like-bigints"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "ca954866",
-   "metadata": {},
-   "source": [
-    "    false false [109] [12345]\n",
-    "    [P]\n",
-    "    [\n",
-    "      [P']\n",
-    "      [ditch-empty-list sub-carry-from-digits]\n",
-    "      [pop swap sub-carry]\n",
-    "      ifte\n",
-    "    ]\n",
-    "    [\n",
-    "        [uncons-two [sub-with-carry] dipd]\n",
-    "        i cons\n",
-    "    ]"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "45a744b7",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "[i cons] genrec"
+    "clear"
    ]
   },
   {
    "cell_type": "markdown",
-   "id": "bc354239",
-   "metadata": {},
-   "source": [
-    "- Did I redefine something?\n",
-    "- Did a definition not make it into the dictionary?\n",
-    "- Trace in the Notebooks should show a trace even if an exception is encountered.\n"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 215,
-   "id": "9b2fd2fb",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "\n",
-      "==== Help on P ====\n",
-      "\n",
-      "P ≡ [bool] ii & not\n",
-      "\n",
-      "---- end ( P )\n",
-      "\n",
-      "\n",
-      "false false [109] [12345] [P] [[[P'] [ditch-empty-list sub-carry-from-digits] [pop swap sub-carry] ifte] uncons-two [sub-with-carry] dipd]"
-     ]
-    }
-   ],
-   "source": [
-    "[P] help"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 216,
-   "id": "3a69a1a2",
+   "id": "73180c15",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "\n",
-      "==== Help on P' ====\n",
-      "\n",
-      "P' ≡ [bool] ii |\n",
-      "\n",
-      "---- end ( P' )\n",
-      "\n",
-      "\n",
-      "false false [109] [12345] [P] [[[P'] [ditch-empty-list sub-carry-from-digits] [pop swap sub-carry] ifte] uncons-two [sub-with-carry] dipd]"
-     ]
-    }
-   ],
    "source": [
-    "[P'] help"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 224,
-   "id": "e29a136f",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "false false [109] [12345]"
-     ]
-    }
-   ],
-   "source": [
-    "pop"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 220,
-   "id": "7499c430",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "false false [109] [12345]"
-     ]
-    }
-   ],
-   "source": [
-    " [109] [12345] "
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 225,
-   "id": "1f38a3a1",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "false false [109] [12345] true"
-     ]
-    }
-   ],
-   "source": [
-    "[P'] nullary\n",
-    " "
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 221,
-   "id": "31103274",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "false false [109] [12345] [[P'] [ditch-empty-list sub-carry-from-digits] [pop swap sub-carry] ifte]"
-     ]
-    }
-   ],
-   "source": [
-    " [[P'] [ditch-empty-list sub-carry-from-digits] [pop swap sub-carry] ifte]\n",
-    " "
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 221,
-   "id": "9f3e739d",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "false false [109] [12345] [[P'] [ditch-empty-list sub-carry-from-digits] [pop swap sub-carry] ifte]"
-     ]
-    }
-   ],
-   "source": [
-    " [[P'] [ditch-empty-list sub-carry-from-digits] [pop swap sub-carry] ifte]\n",
-    " "
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "11639f03",
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    " uncons-two [sub-with-carry] dipd"
+    "#### `sub-carry`\n",
+    "\n",
+    "    sub-carry == pop"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": null,
-   "id": "2889ee5e",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "328334db",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "76e3a1ca",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "93d70133",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 240,
-   "id": "f2bc1f16",
+   "execution_count": 185,
+   "id": "c22775e9",
    "metadata": {},
    "outputs": [
     {
     }
    ],
    "source": [
-    "clear"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 241,
-   "id": "c404eb99",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "false [3 2 1] [6 5 4] [P] [[P'] [ditch-empty-list sub-carry-from-digits] [pop swap pop] ifte] [uncons-two [sub-with-carry] dipd]"
-     ]
-    }
-   ],
-   "source": [
-    "clear\n",
-    "false\n",
-    "[3 2 1] [6 5 4]\n",
-    "[sub-carry-from-digits]\n",
+    "[sub-like-bigints [uncons] dip rest check-gt sub-digits cons] inscribe\n",
+    "[sub-digits initial-carry sub-digits'] inscribe\n",
+    "[sub-digits'\n",
+    "    [sub-carry-from-digits]\n",
     "    [swap pop]\n",
     "    [sub-with-carry]\n",
-    "    build-two-list-combiner"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 242,
-   "id": "74502c4c",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "[2147483645 2147483644 2147483644]"
-     ]
-    }
-   ],
-   "source": [
-    "[i cons] genrec\n"
+    "    build-two-list-combiner\n",
+    "    genrec\n",
+    "] inscribe"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": null,
-   "id": "39a842e5",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 243,
-   "id": "ecb3de02",
+   "execution_count": 186,
+   "id": "ac670030",
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "false [6 5 4] [3 2 1] [P] [[P'] [ditch-empty-list sub-carry-from-digits] [pop swap pop] ifte] [uncons-two [sub-with-carry] dipd]"
+      "true [3 2 1] [6 5 4]"
      ]
     }
    ],
    "source": [
     "clear\n",
-    "false\n",
-    "[3 2 1] [6 5 4] swap\n",
-    "[sub-carry-from-digits]\n",
-    "    [swap pop]\n",
-    "    [sub-with-carry]\n",
-    "    build-two-list-combiner"
+    "true [3 2 1] [6 5 4]"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 244,
-   "id": "0bf21e08",
+   "execution_count": 187,
+   "id": "c19ff340",
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "[3 3 3]"
+      "false false [6 5 4] [3 2 1]"
      ]
     }
    ],
    "source": [
-    "[i cons] genrec\n"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "74054f2f",
-   "metadata": {},
-   "source": [
-    "That sure fucking *looks* like it works."
+    "check-gt initial-carry"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": null,
-   "id": "20462cd5",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 247,
-   "id": "2ab1031c",
+   "execution_count": 188,
+   "id": "8fbba815",
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "true [6 5 4] [3 2 1]"
+      "false [3 3 3]"
      ]
     }
    ],
    "source": [
-    "clear\n",
-    "false\n",
-    "[3 2 1] [6 5 4] check-gt"
+    "sub-digits'"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 248,
-   "id": "1b908ee7",
+   "execution_count": 189,
+   "id": "3b05693f",
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "true [6 5 4] [3 2 1] [P] [[P'] [ditch-empty-list sub-carry-from-digits] [pop swap pop] ifte] [uncons-two [sub-with-carry] dipd]"
+      "[true 5 4 3 2 1] [true 9 0 1]"
      ]
     }
    ],
    "source": [
-    "[sub-carry-from-digits]\n",
-    "    [swap pop]\n",
-    "    [sub-with-carry]\n",
-    "    build-two-list-combiner"
+    "clear\n",
+    "12345 to-bigint 109 to-bigint"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 249,
-   "id": "e223937e",
+   "execution_count": 190,
+   "id": "fc69485b",
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "[2 3 3]"
+      "[true 6 3 2 2 1]"
      ]
     }
    ],
    "source": [
-    "[i cons] genrec\n"
+    "sub-like-bigints"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 251,
-   "id": "a5747b29",
+   "execution_count": 191,
+   "id": "c992d25a",
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "-333"
+      "12236"
      ]
     }
    ],
    "source": [
-    "clear 123 456 -"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "64c14e67",
-   "metadata": {},
-   "source": [
-    "Almost."
+    "from-bigint"
    ]
   },
   {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "c9999912",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "29a0586c",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "bb8cb15e",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "6a5b3ace",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "417e2d45",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
    "cell_type": "markdown",
    "id": "f2b707c1",
    "metadata": {},
     "\n",
     "    base 2147483648\n",
     "    ditch-empty-list [bool] [popd] [pop] ifte\n",
-    "    bool_to_int [0] [1] branch\n",
+    "    bool-to-int [0] [1] branch\n",
     "    uncons-two [uncons] ii swapd\n",
     "\n",
     "    add-with-carry _a0 _a1\n",
-    "    _a0 [bool_to_int] dipd + +\n",
+    "    _a0 [bool-to-int] dipd + +\n",
     "    _a1 base [mod] [>=] clop\n",
     "\n",
     "    add-carry-to-digits [pop not] [popd] [_actd_R0] [i cons] genrec\n",
index 7a92079..27c997b 100644 (file)
@@ -64,7 +64,7 @@ clear
 
 [sub-carry-from-digits [pop not] [popd] [_scfd_R0] [i cons-but-not-leading-zeroes] genrec] inscribe
 [_scfd_R0 uncons 0 swap [sub-with-carry] dip] inscribe
-[cons-but-not-leading-zeroes [[bool] ii | not] [popd] [cons] ifte]
+[cons-but-not-leading-zeroes [P'] [cons] [popd] ifte]
 
 [sub-with-carry _sub-with-carry0 _sub-with-carry1]
 [_sub-with-carry0 rolldown bool-to-int [-] ii]
@@ -92,6 +92,3 @@ build-two-list-combiner
 inscribe
 
 
-true [0 1] sub-carry-from-digits
-
-