This and that.

This commit is contained in:
Simon Forman 2022-10-15 20:04:27 -07:00
parent 74f936efa0
commit ec5036bf63
2 changed files with 119 additions and 25 deletions

View File

@ -21,7 +21,15 @@
"execution_count": 1,
"id": "08a49b81",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2147483648"
]
}
],
"source": [
"1 31 << "
]
@ -39,7 +47,13 @@
"execution_count": 2,
"id": "b34d58ef",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": []
}
],
"source": [
"unit [base] swoncat inscribe"
]
@ -65,7 +79,13 @@
"execution_count": 3,
"id": "35476eac",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": []
}
],
"source": [
"[valid_digit [0 >] [base <] &&] inscribe"
]
@ -75,7 +95,15 @@
"execution_count": 4,
"id": "02a48806",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"32 true 1232147483648 false"
]
}
],
"source": [
"32 valid_digit 1232147483648 valid_digit"
]
@ -85,7 +113,13 @@
"execution_count": 5,
"id": "03a8fe65",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": []
}
],
"source": [
"clear"
]
@ -112,7 +146,15 @@
"execution_count": 6,
"id": "3fc98ccd",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1797196498 5748904729"
]
}
],
"source": [
"12345678901234567890 base divmod swap"
]
@ -122,7 +164,15 @@
"execution_count": 7,
"id": "b838c4cb",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1797196498 1453937433 2"
]
}
],
"source": [
"base divmod swap"
]
@ -132,7 +182,15 @@
"execution_count": 8,
"id": "42c9d92d",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1797196498 1453937433 2 0"
]
}
],
"source": [
"base divmod swap"
]
@ -152,7 +210,15 @@
"execution_count": 9,
"id": "faaac9d6",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1312754386 1501085485 57659106 105448366 58"
]
}
],
"source": [
"clear 1234567890123456789012345678901234567890\n",
"\n",
@ -172,7 +238,15 @@
"execution_count": 10,
"id": "2a613f36",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[58 105448366 57659106 1501085485 1312754386]"
]
}
],
"source": [
"clear [1234567890123456789012345678901234567890]\n",
"\n",
@ -5079,7 +5153,7 @@
},
{
"cell_type": "code",
"execution_count": 211,
"execution_count": 192,
"id": "90abab0f",
"metadata": {},
"outputs": [
@ -5103,7 +5177,7 @@
},
{
"cell_type": "code",
"execution_count": 212,
"execution_count": 193,
"id": "391d87fe",
"metadata": {},
"outputs": [
@ -5119,17 +5193,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 194,
"id": "a7cce3f2",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"123"
]
}
],
"source": [
"123 "
]
},
{
"cell_type": "code",
"execution_count": 213,
"execution_count": 195,
"id": "edb25ebd",
"metadata": {},
"outputs": [
@ -5147,7 +5229,7 @@
},
{
"cell_type": "code",
"execution_count": 214,
"execution_count": 196,
"id": "06e2f309",
"metadata": {},
"outputs": [
@ -5165,7 +5247,7 @@
},
{
"cell_type": "code",
"execution_count": 215,
"execution_count": 197,
"id": "dd47bdae",
"metadata": {},
"outputs": [
@ -5181,6 +5263,23 @@
"[add-bigints [same-sign] [add-like-bigints] [neg-bigint sub-like-bigints] ifte] inscribe"
]
},
{
"cell_type": "markdown",
"id": "de5f0dd7",
"metadata": {},
"source": [
"## Multiplication\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "89d38381",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "f2b707c1",

View File

@ -32,14 +32,7 @@ clear
[add-digits initial-carry add-digits']
[initial-carry false rollup]
[add-digits' [P] [THEN] [R0] [R1] genrec]
[P [bool] ii & not]
[THEN [P'] [THEN'] [ELSE] ifte]
[R0 uncons-two [add-with-carry] dipd]
[R1 i cons]
[P' [bool] ii |]
[THEN' ditch-empty-list add-carry-to-digits]
[ELSE pop swap [] [1 swons] branch]
[same-sign [first] ii xor not]
[extract-sign [uncons] dip rest]
@ -54,6 +47,8 @@ clear
[_btlc0.4 [uncons-two] [dipd] sandwich]
[_btlc0 _btlc0.3 _btlc0.4]
[_btlc1 [[ifte] ccons [P'] swons [P] swap] dip]
[P [bool] ii & not]
[P' [bool] ii |]
[carry [] [1 swons] branch]