From d2048a3846fd4a29680b2ceafff856cb5fd9def4 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Wed, 1 Feb 2023 14:54:07 -0800 Subject: [PATCH] Some notebooks. --- docs/notebooks/BigInts.ipynb | 1662 +++++++---------------------- docs/notebooks/Intro-to-Joy.ipynb | 190 ++++ docs/notebooks/NeoAero.ipynb | 62 ++ 3 files changed, 630 insertions(+), 1284 deletions(-) create mode 100644 docs/notebooks/Intro-to-Joy.ipynb create mode 100644 docs/notebooks/NeoAero.ipynb diff --git a/docs/notebooks/BigInts.ipynb b/docs/notebooks/BigInts.ipynb index 7727681..fb75d04 100644 --- a/docs/notebooks/BigInts.ipynb +++ b/docs/notebooks/BigInts.ipynb @@ -45,6 +45,42 @@ { "cell_type": "code", "execution_count": 2, + "id": "628aa432", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[2147483648]" + ] + } + ], + "source": [ + "unit " + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "b52e0112", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[base 2147483648]" + ] + } + ], + "source": [ + "[base] swoncat" + ] + }, + { + "cell_type": "code", + "execution_count": 4, "id": "b34d58ef", "metadata": {}, "outputs": [ @@ -55,7 +91,7 @@ } ], "source": [ - "unit [base] swoncat inscribe" + " inscribe" ] }, { @@ -76,7 +112,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "id": "35476eac", "metadata": {}, "outputs": [ @@ -92,7 +128,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "id": "02a48806", "metadata": {}, "outputs": [ @@ -110,7 +146,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "id": "03a8fe65", "metadata": {}, "outputs": [ @@ -143,7 +179,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "id": "3fc98ccd", "metadata": {}, "outputs": [ @@ -161,7 +197,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 9, "id": "b838c4cb", "metadata": {}, "outputs": [ @@ -179,7 +215,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 10, "id": "42c9d92d", "metadata": {}, "outputs": [ @@ -207,7 +243,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 11, "id": "faaac9d6", "metadata": {}, "outputs": [ @@ -235,7 +271,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 12, "id": "2a613f36", "metadata": {}, "outputs": [ @@ -265,7 +301,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 13, "id": "e97b149d", "metadata": {}, "outputs": [ @@ -299,7 +335,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 14, "id": "67bb934b", "metadata": {}, "outputs": [ @@ -342,7 +378,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 15, "id": "227271a9", "metadata": {}, "outputs": [ @@ -368,7 +404,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 16, "id": "b6f77ac6", "metadata": {}, "outputs": [ @@ -396,7 +432,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 17, "id": "246c2a58", "metadata": {}, "outputs": [ @@ -416,7 +452,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 18, "id": "a571e98a", "metadata": {}, "outputs": [ @@ -440,7 +476,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 19, "id": "5a72ce30", "metadata": {}, "outputs": [ @@ -464,7 +500,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 20, "id": "59514dcd", "metadata": {}, "outputs": [ @@ -490,7 +526,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 21, "id": "f3c19364", "metadata": {}, "outputs": [ @@ -508,7 +544,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 22, "id": "998512c6", "metadata": {}, "outputs": [ @@ -577,7 +613,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 23, "id": "bdd5ceab", "metadata": {}, "outputs": [ @@ -602,7 +638,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 24, "id": "244aa4e5", "metadata": {}, "outputs": [ @@ -627,7 +663,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 25, "id": "b0b1afb0", "metadata": {}, "outputs": [ @@ -648,6 +684,22 @@ "popdd" ] }, + { + "cell_type": "code", + "execution_count": 52, + "id": "818f51bc", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [] + } + ], + "source": [ + "clear" + ] + }, { "cell_type": "markdown", "id": "7497680b", @@ -658,16 +710,14 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 53, "id": "d15747ee", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", - "text": [ - "2147483648 23" - ] + "text": [] } ], "source": [ @@ -680,7 +730,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 54, "id": "c77d58c5", "metadata": {}, "outputs": [ @@ -693,14 +743,14 @@ } ], "source": [ - "clear 1 0 [1312754386 1501085485 57659106 105448366 58]\n", + "1 0 [1312754386 1501085485 57659106 105448366 58]\n", "\n", "from-bigint'" ] }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 55, "id": "b2b076c9", "metadata": {}, "outputs": [ @@ -718,7 +768,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 56, "id": "778ecfb2", "metadata": {}, "outputs": [ @@ -736,7 +786,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 57, "id": "682ed5e2", "metadata": {}, "outputs": [ @@ -754,7 +804,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 58, "id": "5bb0973a", "metadata": {}, "outputs": [ @@ -780,7 +830,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 59, "id": "4736f46a", "metadata": {}, "outputs": [ @@ -798,7 +848,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 60, "id": "8615243e", "metadata": {}, "outputs": [ @@ -824,7 +874,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 61, "id": "e2f8d6cb", "metadata": {}, "outputs": [ @@ -850,7 +900,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 62, "id": "e09c99c2", "metadata": {}, "outputs": [ @@ -876,7 +926,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 63, "id": "cc990e1e", "metadata": {}, "outputs": [ @@ -914,7 +964,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 64, "id": "fb5d4a30", "metadata": {}, "outputs": [ @@ -933,7 +983,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 65, "id": "b897a3bd", "metadata": {}, "outputs": [ @@ -951,7 +1001,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 66, "id": "d1efc1ae", "metadata": {}, "outputs": [ @@ -969,7 +1019,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 67, "id": "1ad99efa", "metadata": {}, "outputs": [ @@ -1025,7 +1075,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 68, "id": "f33ca7b0", "metadata": {}, "outputs": [ @@ -1057,7 +1107,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 69, "id": "b2d4f3b2", "metadata": {}, "outputs": [ @@ -1083,7 +1133,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 70, "id": "d87fa971", "metadata": {}, "outputs": [ @@ -1133,7 +1183,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 71, "id": "491c0846", "metadata": {}, "outputs": [ @@ -1184,7 +1234,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 72, "id": "bd51792f", "metadata": {}, "outputs": [ @@ -1209,7 +1259,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 73, "id": "fbf134e2", "metadata": {}, "outputs": [ @@ -1227,7 +1277,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 74, "id": "90db3359", "metadata": {}, "outputs": [ @@ -1283,7 +1333,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 75, "id": "4fce2757", "metadata": {}, "outputs": [ @@ -1309,7 +1359,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 76, "id": "e86b7b90", "metadata": {}, "outputs": [ @@ -1336,7 +1386,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 77, "id": "cd70e18e", "metadata": {}, "outputs": [ @@ -1356,7 +1406,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 78, "id": "a27ff9f0", "metadata": {}, "outputs": [ @@ -1386,7 +1436,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 79, "id": "74a59ab5", "metadata": {}, "outputs": [ @@ -1406,7 +1456,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 80, "id": "3a8f5078", "metadata": {}, "outputs": [ @@ -1449,7 +1499,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 81, "id": "c05bcd8e", "metadata": {}, "outputs": [ @@ -1476,7 +1526,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 82, "id": "03649114", "metadata": {}, "outputs": [ @@ -1496,7 +1546,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 83, "id": "9dca0fbc", "metadata": {}, "outputs": [ @@ -1516,7 +1566,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 84, "id": "c8f01d7d", "metadata": {}, "outputs": [ @@ -1536,7 +1586,7 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 85, "id": "a1e77990", "metadata": {}, "outputs": [ @@ -1556,7 +1606,7 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 86, "id": "b46a62ba", "metadata": {}, "outputs": [ @@ -1681,7 +1731,7 @@ }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 87, "id": "c8f1aa44", "metadata": {}, "outputs": [ @@ -1711,7 +1761,7 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 88, "id": "1fa115d9", "metadata": {}, "outputs": [ @@ -1731,7 +1781,7 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 89, "id": "79d9c526", "metadata": {}, "outputs": [ @@ -1751,7 +1801,7 @@ }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 90, "id": "bb030214", "metadata": {}, "outputs": [ @@ -1771,7 +1821,7 @@ }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 91, "id": "5e0a05af", "metadata": {}, "outputs": [ @@ -1791,7 +1841,7 @@ }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 92, "id": "7c730d6d", "metadata": {}, "outputs": [ @@ -1809,7 +1859,7 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 93, "id": "33bc080f", "metadata": {}, "outputs": [ @@ -1838,7 +1888,7 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 94, "id": "1ac813da", "metadata": {}, "outputs": [ @@ -1862,7 +1912,7 @@ }, { "cell_type": "code", - "execution_count": 66, + "execution_count": 95, "id": "5e5ddf74", "metadata": {}, "outputs": [ @@ -1882,7 +1932,7 @@ }, { "cell_type": "code", - "execution_count": 67, + "execution_count": 96, "id": "c57d1fb2", "metadata": {}, "outputs": [ @@ -1902,7 +1952,7 @@ }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 97, "id": "59b1338c", "metadata": {}, "outputs": [ @@ -1964,7 +2014,7 @@ }, { "cell_type": "code", - "execution_count": 69, + "execution_count": 98, "id": "78dec757", "metadata": {}, "outputs": [ @@ -1993,18 +2043,10 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": null, "id": "5b4bd2fe", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 4 [2 3] [5 6]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -2015,16 +2057,10 @@ }, { "cell_type": "code", - "execution_count": 71, + "execution_count": null, "id": "f284ea19", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] @@ -2065,16 +2101,10 @@ }, { "cell_type": "code", - "execution_count": 72, + "execution_count": null, "id": "8adffacb", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "[add-digits initial-carry add-digits'] inscribe\n", "[add-digits' [P] [THEN] [R0] [R1] genrec] inscribe\n", @@ -2090,108 +2120,60 @@ }, { "cell_type": "code", - "execution_count": 73, + "execution_count": null, "id": "5b2e5738", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[3 2 1] [1 1 1]" - ] - } - ], + "outputs": [], "source": [ "[3 2 1] [1 1 1]" ] }, { "cell_type": "code", - "execution_count": 74, + "execution_count": null, "id": "cd7ac0b9", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[4 3 2]" - ] - } - ], + "outputs": [], "source": [ "add-digits" ] }, { "cell_type": "code", - "execution_count": 75, + "execution_count": null, "id": "50f2e62c", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[4 3 2] [2147483647]" - ] - } - ], + "outputs": [], "source": [ "base -- unit" ] }, { "cell_type": "code", - "execution_count": 76, + "execution_count": null, "id": "54ca630f", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[3 4 2]" - ] - } - ], + "outputs": [], "source": [ "add-digits" ] }, { "cell_type": "code", - "execution_count": 77, + "execution_count": null, "id": "27bb4638", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[3 4 2] [2147483647 2147483647 2147483647]" - ] - } - ], + "outputs": [], "source": [ "base -- dup dup unit ccons" ] }, { "cell_type": "code", - "execution_count": 78, + "execution_count": null, "id": "4d2d446a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[2 4 2 1]" - ] - } - ], + "outputs": [], "source": [ "add-digits" ] @@ -2206,18 +2188,10 @@ }, { "cell_type": "code", - "execution_count": 79, + "execution_count": null, "id": "c187ffff", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1242" - ] - } - ], + "outputs": [], "source": [ "clear 243 999 +" ] @@ -2242,18 +2216,10 @@ }, { "cell_type": "code", - "execution_count": 80, + "execution_count": null, "id": "f2987cd7", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[true 123] [true 456]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -2262,36 +2228,20 @@ }, { "cell_type": "code", - "execution_count": 81, + "execution_count": null, "id": "393623c3", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "[first] ii xor not" ] }, { "cell_type": "code", - "execution_count": 82, + "execution_count": null, "id": "20ce6f9f", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[true 123] [true 456]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -2300,72 +2250,40 @@ }, { "cell_type": "code", - "execution_count": 83, + "execution_count": null, "id": "b355996b", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true [123] [true 456]" - ] - } - ], + "outputs": [], "source": [ "[uncons] dip" ] }, { "cell_type": "code", - "execution_count": 84, + "execution_count": null, "id": "3d4a27b1", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true [123] [456]" - ] - } - ], + "outputs": [], "source": [ "rest " ] }, { "cell_type": "code", - "execution_count": 85, + "execution_count": null, "id": "ac5990b4", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true [579]" - ] - } - ], + "outputs": [], "source": [ "add-digits" ] }, { "cell_type": "code", - "execution_count": 86, + "execution_count": null, "id": "11b3384e", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[true 579]" - ] - } - ], + "outputs": [], "source": [ " cons" ] @@ -2380,18 +2298,10 @@ }, { "cell_type": "code", - "execution_count": 87, + "execution_count": null, "id": "e75d711e", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[true 579]" - ] - } - ], + "outputs": [], "source": [ "[same-sign [first] ii xor not] inscribe\n", "[add-like-bigints [uncons] dip rest add-digits cons] inscribe\n", @@ -2400,52 +2310,30 @@ }, { "cell_type": "code", - "execution_count": 88, + "execution_count": null, "id": "e69471ba", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[true 579] [true 2147483647]" - ] - } - ], + "outputs": [], "source": [ "base -- to-bigint" ] }, { "cell_type": "code", - "execution_count": 89, + "execution_count": null, "id": "29963839", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[true 578 1]" - ] - } - ], + "outputs": [], "source": [ "add-bigints" ] }, { "cell_type": "code", - "execution_count": 90, + "execution_count": null, "id": "dac1c858", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] @@ -2665,52 +2553,30 @@ }, { "cell_type": "code", - "execution_count": 91, + "execution_count": null, "id": "55f64814", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "[sandwich swap [cons] dip swoncat] inscribe" ] }, { "cell_type": "code", - "execution_count": 92, + "execution_count": null, "id": "04e2d0d0", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[B] [A] [C]" - ] - } - ], + "outputs": [], "source": [ "clear [B] [A] [C]" ] }, { "cell_type": "code", - "execution_count": 93, + "execution_count": null, "id": "a28d9323", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[A [B] C]" - ] - } - ], + "outputs": [], "source": [ "sandwich" ] @@ -2737,16 +2603,10 @@ }, { "cell_type": "code", - "execution_count": 94, + "execution_count": null, "id": "bc16275c", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear\n", "[_foo0.0 [[ditch-empty-list] swoncat] dip] inscribe\n", @@ -2765,36 +2625,20 @@ }, { "cell_type": "code", - "execution_count": 95, + "execution_count": null, "id": "c517da7a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[ditch-empty-list A] [pop B] [uncons-two [C] dipd]" - ] - } - ], + "outputs": [], "source": [ "[A] [B] [C] _foo0" ] }, { "cell_type": "code", - "execution_count": 96, + "execution_count": null, "id": "3f482224", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[P] [[P'] [ditch-empty-list A] [pop B] ifte] [uncons-two [C] dipd]" - ] - } - ], + "outputs": [], "source": [ "_foo1" ] @@ -2809,18 +2653,10 @@ }, { "cell_type": "code", - "execution_count": 97, + "execution_count": null, "id": "4b90e664", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[P] [[P'] [ditch-empty-list add-carry-to-digits] [pop swap carry] ifte] [uncons-two [add-with-carry] dipd]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "[add-carry-to-digits]\n", @@ -2860,18 +2696,10 @@ }, { "cell_type": "code", - "execution_count": 98, + "execution_count": null, "id": "ff88e2c1", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "false [3 2 1] [6 5 4] [P] [[P'] [ditch-empty-list add-carry-to-digits] [pop swap carry] ifte] [uncons-two [add-with-carry] dipd]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -2885,36 +2713,22 @@ }, { "cell_type": "code", - "execution_count": 99, + "execution_count": null, "id": "941a4426", "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[9 7 5]" - ] - } - ], + "outputs": [], "source": [ "[i cons] genrec" ] }, { "cell_type": "code", - "execution_count": 100, + "execution_count": null, "id": "917600dd", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear\n", "[build-two-list-combiner _foo0 _foo1 [i cons]] inscribe\n", @@ -2923,18 +2737,10 @@ }, { "cell_type": "code", - "execution_count": 101, + "execution_count": null, "id": "21f6b0e4", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "false [3 2 1] [6 5 4] [P] [[P'] [ditch-empty-list add-carry-to-digits] [pop swap carry] ifte] [uncons-two [add-with-carry] dipd] [i cons]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -2944,54 +2750,30 @@ }, { "cell_type": "code", - "execution_count": 102, + "execution_count": null, "id": "4a8819fc", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[9 7 5]" - ] - } - ], + "outputs": [], "source": [ "genrec" ] }, { "cell_type": "code", - "execution_count": 103, + "execution_count": null, "id": "5d451c1e", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[9 7 5]" - ] - } - ], + "outputs": [], "source": [ "[base 10] inscribe" ] }, { "cell_type": "code", - "execution_count": 104, + "execution_count": null, "id": "28fefe8a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[true 6 5 4 3 2 1]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -3003,16 +2785,10 @@ }, { "cell_type": "code", - "execution_count": 105, + "execution_count": null, "id": "fa37c40c", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] @@ -3029,18 +2805,10 @@ }, { "cell_type": "code", - "execution_count": 106, + "execution_count": null, "id": "850a1421", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[P] [[P'] [ditch-empty-list add-carry-to-digits] [pop swap carry] ifte] [uncons-two [add-with-carry] dipd] [i cons]" - ] - } - ], + "outputs": [], "source": [ "[add-carry-to-digits]\n", "[swap carry]\n", @@ -3058,34 +2826,20 @@ }, { "cell_type": "code", - "execution_count": 107, + "execution_count": null, "id": "4b6005fc", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[add-digits' [P] [[P'] [ditch-empty-list add-carry-to-digits] [pop swap carry] ifte] [uncons-two [add-with-carry] dipd] [i cons] genrec]" - ] - } - ], + "outputs": [], "source": [ "[genrec] ccons ccons [add-digits'] swoncat" ] }, { "cell_type": "code", - "execution_count": 108, + "execution_count": null, "id": "c616033e", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ " inscribe" ] @@ -3100,70 +2854,40 @@ }, { "cell_type": "code", - "execution_count": 109, + "execution_count": null, "id": "1a18ddd7", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[7 5 3]" - ] - } - ], + "outputs": [], "source": [ "false [3 2 1] [4 3 2] add-digits'" ] }, { "cell_type": "code", - "execution_count": 110, + "execution_count": null, "id": "3c639487", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "false [7 5 3] [9]" - ] - } - ], + "outputs": [], "source": [ "false swap base -- unit" ] }, { "cell_type": "code", - "execution_count": 111, + "execution_count": null, "id": "c9222cab", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[6 6 3]" - ] - } - ], + "outputs": [], "source": [ "add-digits'" ] }, { "cell_type": "code", - "execution_count": 112, + "execution_count": null, "id": "f3bc8d28", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] @@ -3178,88 +2902,50 @@ }, { "cell_type": "code", - "execution_count": 113, + "execution_count": null, "id": "b4a71b70", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[true 4 3 2 1] [true 9 9 9]" - ] - } - ], + "outputs": [], "source": [ "1234 999 [to-bigint] ii " ] }, { "cell_type": "code", - "execution_count": 114, + "execution_count": null, "id": "6aba84ae", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[true 3 3 2 2]" - ] - } - ], + "outputs": [], "source": [ "add-bigints" ] }, { "cell_type": "code", - "execution_count": 115, + "execution_count": null, "id": "d5dc4dce", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2233" - ] - } - ], + "outputs": [], "source": [ "from-bigint" ] }, { "cell_type": "code", - "execution_count": 116, + "execution_count": null, "id": "2e9ab2c2", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2233 2233" - ] - } - ], + "outputs": [], "source": [ "1234 999 +" ] }, { "cell_type": "code", - "execution_count": 117, + "execution_count": null, "id": "080d81a3", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] @@ -3357,34 +3043,20 @@ }, { "cell_type": "code", - "execution_count": 118, + "execution_count": null, "id": "9c50bd24", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "[length [bool not] [pop 0] [rest] [i ++] genrec] inscribe" ] }, { "cell_type": "code", - "execution_count": 119, + "execution_count": null, "id": "4c1dbabd", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0" - ] - } - ], + "outputs": [], "source": [ "clear\n", "[] length" @@ -3392,18 +3064,10 @@ }, { "cell_type": "code", - "execution_count": 120, + "execution_count": null, "id": "ef683ade", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4" - ] - } - ], + "outputs": [], "source": [ "clear\n", "[this is a list] length" @@ -3411,18 +3075,10 @@ }, { "cell_type": "code", - "execution_count": 121, + "execution_count": null, "id": "ff52920a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1 2 3] [4 5] 3 2" - ] - } - ], + "outputs": [], "source": [ "clear\n", "[1 2 3] [4 5] over over [length] app2" @@ -3430,18 +3086,10 @@ }, { "cell_type": "code", - "execution_count": 122, + "execution_count": null, "id": "be946f53", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[4 5] [1 2 3]" - ] - } - ], + "outputs": [], "source": [ "[swap][6][7]cmp" ] @@ -3456,52 +3104,30 @@ }, { "cell_type": "code", - "execution_count": 123, + "execution_count": null, "id": "056e3072", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] }, { "cell_type": "code", - "execution_count": 124, + "execution_count": null, "id": "02d4e38e", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "[1 2 3] [4 5 6] [bool]ii &" ] }, { "cell_type": "code", - "execution_count": 125, + "execution_count": null, "id": "5683eb84", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[1 4] [2 5] [3 6]]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "[1 2 3] [4 5 6]\n", @@ -3514,18 +3140,10 @@ }, { "cell_type": "code", - "execution_count": 126, + "execution_count": null, "id": "a4e1f728", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[1 4] [2 5] [3 6]]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "[1 2 3] [4 5 6]\n", @@ -3538,16 +3156,10 @@ }, { "cell_type": "code", - "execution_count": 127, + "execution_count": null, "id": "dc7c151a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] @@ -3598,34 +3210,20 @@ }, { "cell_type": "code", - "execution_count": 128, + "execution_count": null, "id": "50c2669a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ " [xR1 uncons-two [unit cons swons] dipd] inscribe" ] }, { "cell_type": "code", - "execution_count": 129, + "execution_count": null, "id": "1bbf3465", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[] [3 2 1] [4 5 6]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -3634,34 +3232,20 @@ }, { "cell_type": "code", - "execution_count": 130, + "execution_count": null, "id": "5a9347f6", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[1 6] [2 5] [3 4]] [] []" - ] - } - ], + "outputs": [], "source": [ "xR1 xR1 xR1" ] }, { "cell_type": "code", - "execution_count": 131, + "execution_count": null, "id": "69b18847", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear\n", "[xP [bool] ii & not] inscribe" @@ -3669,18 +3253,10 @@ }, { "cell_type": "code", - "execution_count": 132, + "execution_count": null, "id": "0b29370d", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[2 4] [3 5]] [1] []" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -3689,18 +3265,10 @@ }, { "cell_type": "code", - "execution_count": 133, + "execution_count": null, "id": "32ce148e", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[2 5] [3 4]] [] [1]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -3709,18 +3277,10 @@ }, { "cell_type": "code", - "execution_count": 134, + "execution_count": null, "id": "4efc8f76", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[1 3] [2 4] [3 5]] [] []" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -3765,18 +3325,10 @@ }, { "cell_type": "code", - "execution_count": 135, + "execution_count": null, "id": "7d973f7f", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "clear\n", "[][][1]\n", @@ -3794,18 +3346,10 @@ }, { "cell_type": "code", - "execution_count": 136, + "execution_count": null, "id": "9239e0c4", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "false" - ] - } - ], + "outputs": [], "source": [ "clear\n", "[][1][]\n", @@ -3823,18 +3367,10 @@ }, { "cell_type": "code", - "execution_count": 137, + "execution_count": null, "id": "0c58a6e0", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[23 1]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "[1][][]\n", @@ -3879,18 +3415,10 @@ }, { "cell_type": "code", - "execution_count": 138, + "execution_count": null, "id": "7f302157", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -3899,18 +3427,10 @@ }, { "cell_type": "code", - "execution_count": 139, + "execution_count": null, "id": "d25ef02e", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[true true true]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -3927,16 +3447,10 @@ }, { "cell_type": "code", - "execution_count": 140, + "execution_count": null, "id": "06e0ffcb", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -3954,36 +3468,20 @@ }, { "cell_type": "code", - "execution_count": 141, + "execution_count": null, "id": "b2428f49", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "clear [[1 3] [2 4] [3 5]] compare-pairs" ] }, { "cell_type": "code", - "execution_count": 142, + "execution_count": null, "id": "4ef5f503", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "clear [[1 3] [3 3] [3 5]] compare-pairs" ] @@ -3998,16 +3496,10 @@ }, { "cell_type": "code", - "execution_count": 143, + "execution_count": null, "id": "7f060f83", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -4033,124 +3525,70 @@ }, { "cell_type": "code", - "execution_count": 144, + "execution_count": null, "id": "8d74a801", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "clear [[1 0] [2 2] [3 3]] compare-pairs" ] }, { "cell_type": "code", - "execution_count": 145, + "execution_count": null, "id": "0104d2b0", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "clear [[1 1] [2 2] [3 3]] compare-pairs" ] }, { "cell_type": "code", - "execution_count": 146, + "execution_count": null, "id": "4728d141", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "clear [[1 2] [2 2] [3 3]] compare-pairs" ] }, { "cell_type": "code", - "execution_count": 147, + "execution_count": null, "id": "bfb5e62c", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] }, { "cell_type": "code", - "execution_count": 148, + "execution_count": null, "id": "7983881c", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "clear [[1 1] [2 1] [3 3]] compare-pairs" ] }, { "cell_type": "code", - "execution_count": 149, + "execution_count": null, "id": "677757c5", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "clear [[1 1] [2 2] [3 3]] compare-pairs" ] }, { "cell_type": "code", - "execution_count": 150, + "execution_count": null, "id": "5691f813", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "clear [[1 1] [2 3] [3 3]] compare-pairs" ] @@ -4165,18 +3603,10 @@ }, { "cell_type": "code", - "execution_count": 151, + "execution_count": null, "id": "b95fe984", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "clear\n", "[[1 1] [2 1] [3 3]] [] []\n", @@ -4194,18 +3624,10 @@ }, { "cell_type": "code", - "execution_count": 152, + "execution_count": null, "id": "b5ddac15", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "[BASE\n", " [bool]\n", @@ -4222,18 +3644,10 @@ }, { "cell_type": "code", - "execution_count": 153, + "execution_count": null, "id": "d4077376", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[] [3 2 1] [4 5 6]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -4242,36 +3656,20 @@ }, { "cell_type": "code", - "execution_count": 154, + "execution_count": null, "id": "ac840996", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "[xP] [BASE] [xR1] tailrec" ] }, { "cell_type": "code", - "execution_count": 155, + "execution_count": null, "id": "e7c3b141", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[] [4 5 6] [3 2 1]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -4280,36 +3678,20 @@ }, { "cell_type": "code", - "execution_count": 156, + "execution_count": null, "id": "95c7308d", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "false" - ] - } - ], + "outputs": [], "source": [ "[xP] [BASE] [xR1] tailrec" ] }, { "cell_type": "code", - "execution_count": 157, + "execution_count": null, "id": "5e43ba80", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[] [3 2 1] [3 2 1]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -4318,104 +3700,60 @@ }, { "cell_type": "code", - "execution_count": 158, + "execution_count": null, "id": "20070426", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "[xP] [BASE] [xR1] tailrec" ] }, { "cell_type": "code", - "execution_count": 159, + "execution_count": null, "id": "c97b0df9", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] }, { "cell_type": "code", - "execution_count": 160, + "execution_count": null, "id": "980a1bbf", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "[gt-bigint <<{} [xP] [BASE] [xR1] tailrec] inscribe" ] }, { "cell_type": "code", - "execution_count": 161, + "execution_count": null, "id": "4f429421", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "clear [3 2 1] [4 5 6] gt-bigint" ] }, { "cell_type": "code", - "execution_count": 162, + "execution_count": null, "id": "5a6419ee", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "false" - ] - } - ], + "outputs": [], "source": [ "clear [3 2 1] [4 5 6] swap gt-bigint" ] }, { "cell_type": "code", - "execution_count": 163, + "execution_count": null, "id": "cd586291", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true" - ] - } - ], + "outputs": [], "source": [ "clear [3 2 1] dup gt-bigint" ] @@ -4430,36 +3768,20 @@ }, { "cell_type": "code", - "execution_count": 164, + "execution_count": null, "id": "35fb22d2", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[4 5 6] [3 2 1]" - ] - } - ], + "outputs": [], "source": [ "clear [3 2 1] [4 5 6] [gt-bigint] [swap] [] ifte" ] }, { "cell_type": "code", - "execution_count": 165, + "execution_count": null, "id": "36d74e5b", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[4 5 6] [3 2 1]" - ] - } - ], + "outputs": [], "source": [ "clear [4 5 6] [3 2 1] [gt-bigint] [swap] [] ifte" ] @@ -4482,16 +3804,10 @@ }, { "cell_type": "code", - "execution_count": 166, + "execution_count": null, "id": "dd645337", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear\n", "[check-gt [gt-bigint] [swap [not] dipd] [] ifte] inscribe" @@ -4499,52 +3815,30 @@ }, { "cell_type": "code", - "execution_count": 167, + "execution_count": null, "id": "935552d4", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "false [4 5 6] [3 2 1]" - ] - } - ], + "outputs": [], "source": [ "false [4 5 6] [3 2 1]" ] }, { "cell_type": "code", - "execution_count": 168, + "execution_count": null, "id": "05100765", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "false [4 5 6] [3 2 1]" - ] - } - ], + "outputs": [], "source": [ "check-gt" ] }, { "cell_type": "code", - "execution_count": 169, + "execution_count": null, "id": "7ac873d4", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] @@ -4648,16 +3942,10 @@ }, { "cell_type": "code", - "execution_count": 170, + "execution_count": null, "id": "c360cc7b", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "[_sub-with-carry0 rolldown bool-to-int [-] ii] inscribe\n", "[_sub-with-carry1 [base + base mod] [0 <] cleave] inscribe\n", @@ -4666,54 +3954,32 @@ }, { "cell_type": "code", - "execution_count": 171, + "execution_count": null, "id": "3a84adff", "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "false 3 9" - ] - } - ], + "outputs": [], "source": [ "clear false 3 base --" ] }, { "cell_type": "code", - "execution_count": 172, + "execution_count": null, "id": "0dcdc968", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4 true" - ] - } - ], + "outputs": [], "source": [ "sub-with-carry" ] }, { "cell_type": "code", - "execution_count": 173, + "execution_count": null, "id": "2d60492d", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] @@ -4780,16 +4046,10 @@ }, { "cell_type": "code", - "execution_count": 174, + "execution_count": null, "id": "20c8ad40", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "[sub-carry-from-digits\n", " [pop not]\n", @@ -4811,18 +4071,10 @@ }, { "cell_type": "code", - "execution_count": 175, + "execution_count": null, "id": "92201303", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[3 2 1]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -4831,18 +4083,10 @@ }, { "cell_type": "code", - "execution_count": 176, + "execution_count": null, "id": "1a1d7cdc", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[9 0]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -4851,18 +4095,10 @@ }, { "cell_type": "code", - "execution_count": 177, + "execution_count": null, "id": "39ce9c6a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[2 2 1]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -4871,18 +4107,10 @@ }, { "cell_type": "code", - "execution_count": 178, + "execution_count": null, "id": "a93e916e", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[9 9 0]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -4891,16 +4119,10 @@ }, { "cell_type": "code", - "execution_count": 179, + "execution_count": null, "id": "c2273ff3", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] @@ -4919,32 +4141,20 @@ }, { "cell_type": "code", - "execution_count": 180, + "execution_count": null, "id": "d8c7f7a5", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "[cons-but-not-leading-zeroes [[bool] ii | not] [popd] [cons] ifte] inscribe" ] }, { "cell_type": "code", - "execution_count": 181, + "execution_count": null, "id": "875aaafa", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "[sub-carry-from-digits\n", " [pop not]\n", @@ -4957,34 +4167,20 @@ }, { "cell_type": "code", - "execution_count": 182, + "execution_count": null, "id": "bd2447b6", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "[_scfd_R0 uncons 0 swap [sub-with-carry] dip] inscribe" ] }, { "cell_type": "code", - "execution_count": 183, + "execution_count": null, "id": "ffaf1fcc", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[9 9]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "\n", @@ -4993,16 +4189,10 @@ }, { "cell_type": "code", - "execution_count": 184, + "execution_count": null, "id": "8a2b2165", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] @@ -5019,16 +4209,10 @@ }, { "cell_type": "code", - "execution_count": 185, + "execution_count": null, "id": "c22775e9", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "[sub-like-bigints [uncons] dip rest check-gt sub-digits cons] inscribe\n", "[sub-digits initial-carry sub-digits'] inscribe\n", @@ -5043,18 +4227,10 @@ }, { "cell_type": "code", - "execution_count": 186, + "execution_count": null, "id": "ac670030", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true [3 2 1] [6 5 4]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "true [3 2 1] [6 5 4]" @@ -5062,54 +4238,30 @@ }, { "cell_type": "code", - "execution_count": 187, + "execution_count": null, "id": "c19ff340", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "false false [6 5 4] [3 2 1]" - ] - } - ], + "outputs": [], "source": [ "check-gt initial-carry" ] }, { "cell_type": "code", - "execution_count": 188, + "execution_count": null, "id": "8fbba815", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "false [3 3 3]" - ] - } - ], + "outputs": [], "source": [ "sub-digits'" ] }, { "cell_type": "code", - "execution_count": 189, + "execution_count": null, "id": "3b05693f", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[true 5 4 3 2 1] [true 9 0 1]" - ] - } - ], + "outputs": [], "source": [ "clear\n", "12345 to-bigint 109 to-bigint" @@ -5117,52 +4269,30 @@ }, { "cell_type": "code", - "execution_count": 190, + "execution_count": null, "id": "fc69485b", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[true 6 3 2 2 1]" - ] - } - ], + "outputs": [], "source": [ "sub-like-bigints" ] }, { "cell_type": "code", - "execution_count": 191, + "execution_count": null, "id": "c992d25a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "12236" - ] - } - ], + "outputs": [], "source": [ "from-bigint" ] }, { "cell_type": "code", - "execution_count": 192, + "execution_count": null, "id": "90abab0f", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear" ] @@ -5177,86 +4307,50 @@ }, { "cell_type": "code", - "execution_count": 193, + "execution_count": null, "id": "391d87fe", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "[neg-bigint [not] infra] inscribe" ] }, { "cell_type": "code", - "execution_count": 194, + "execution_count": null, "id": "a7cce3f2", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "123" - ] - } - ], + "outputs": [], "source": [ "123 " ] }, { "cell_type": "code", - "execution_count": 195, + "execution_count": null, "id": "edb25ebd", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-123" - ] - } - ], + "outputs": [], "source": [ "to-bigint neg-bigint from-bigint" ] }, { "cell_type": "code", - "execution_count": 196, + "execution_count": null, "id": "06e2f309", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "123" - ] - } - ], + "outputs": [], "source": [ "to-bigint neg-bigint from-bigint" ] }, { "cell_type": "code", - "execution_count": 197, + "execution_count": null, "id": "dd47bdae", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [] - } - ], + "outputs": [], "source": [ "clear\n", "[sub-bigints [same-sign] [sub-like-bigints] [neg-bigint add-like-bigints] ifte] inscribe\n", diff --git a/docs/notebooks/Intro-to-Joy.ipynb b/docs/notebooks/Intro-to-Joy.ipynb new file mode 100644 index 0000000..950c155 --- /dev/null +++ b/docs/notebooks/Intro-to-Joy.ipynb @@ -0,0 +1,190 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "ff8ca725", + "metadata": {}, + "source": [ + "In the Thun dialect of Joy there are only four kinds of things:\n", + "\n", + "- Integers (positive and negative, unbounded)\n", + "- Boolean values \"true\" and \"false\"\n", + "- Lists of things enclosed by square brackets (\"\\[\" and \"\\]\").\n", + "- Symbols (names) which denote functions.\n", + "\n", + "When the interpreter encounters a literal value (an integer, Boolean, or list) it is put onto the **stack**:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "78e3e3fe", + "metadata": {}, + "outputs": [], + "source": [ + "1 2 3 true false [4 5 true []] " + ] + }, + { + "cell_type": "markdown", + "id": "68c241e5", + "metadata": {}, + "source": [ + "When symbols are encountered they are looked up in the **dictionary** and the function they denote is evaluated:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "68f0292a", + "metadata": {}, + "outputs": [], + "source": [ + "cons" + ] + }, + { + "cell_type": "markdown", + "id": "9b0205ff", + "metadata": {}, + "source": [ + "There is a special function `trace` that will print a *trace* of the evalutation of an expression step-by-step. (It's like the `i` combinator with side-effects):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e9638d25", + "metadata": {}, + "outputs": [], + "source": [ + "[cons] trace" + ] + }, + { + "cell_type": "markdown", + "id": "a0fc74d7", + "metadata": {}, + "source": [ + "Let's see some other functions." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "18dfa724", + "metadata": {}, + "outputs": [], + "source": [ + "[pop unit ccons]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5b324b9e", + "metadata": {}, + "outputs": [], + "source": [ + "trace" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "656740eb", + "metadata": {}, + "outputs": [], + "source": [ + "sum" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "10e61981", + "metadata": {}, + "outputs": [], + "source": [ + "clear" + ] + }, + { + "cell_type": "markdown", + "id": "524c3507", + "metadata": {}, + "source": [ + "Control flow is achieved by special functions called **combinators** that accept quoted expressions on the stack and prefix them in various ways to the pending expression. The four core combinators are:\n", + "\n", + "* `branch` - do one thing or another based on a condition.\n", + "* `loop` - do one thing over again (or not.)\n", + "* sequence - do one thing then another (not a combinator, this is the default operation.)\n", + "* `fork` (do things independently of each other, parallel.)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d331ecca", + "metadata": {}, + "outputs": [], + "source": [ + "23" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c68bc68d", + "metadata": {}, + "outputs": [], + "source": [ + "dup 0 < [] [0 swap -]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "84a7fc4a", + "metadata": {}, + "outputs": [], + "source": [ + "[branch] trace" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fa9fc0c9", + "metadata": {}, + "outputs": [], + "source": [ + "neg" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "80708666", + "metadata": {}, + "outputs": [], + "source": [ + "[dup 0 < [] [0 swap -] branch] trace" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Joypy", + "language": "", + "name": "thun" + }, + "language_info": { + "file_extension": ".joy", + "mimetype": "text/plain", + "name": "Joy" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/docs/notebooks/NeoAero.ipynb b/docs/notebooks/NeoAero.ipynb new file mode 100644 index 0000000..1be51f8 --- /dev/null +++ b/docs/notebooks/NeoAero.ipynb @@ -0,0 +1,62 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "6ac9e0d5", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "6" + ] + } + ], + "source": [ + "6" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "1bac5df8", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "24" + ] + } + ], + "source": [ + "4 *" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7e65a67a", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Joypy", + "language": "", + "name": "thun" + }, + "language_info": { + "file_extension": ".joy", + "mimetype": "text/plain", + "name": "Joy" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}