diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c8acf6..4052640 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ However, because this book is a rework of the first edition by Bernard Legrand, this changelog also marks with [n] content that is new in this rework. +## 0.6.1 + + - Add section “More about DISPLAY” to chapter “Nested Arrays (Continued)”. + - Fix bad cross-reference. + + ## 0.6.0 - [n] Add chapter “Tacit Programming”: diff --git a/docs/Execute-and-Format-Control.ipynb b/docs/Execute-and-Format-Control.ipynb index 581fc84..7b73752 100644 --- a/docs/Execute-and-Format-Control.ipynb +++ b/docs/Execute-and-Format-Control.ipynb @@ -7818,7 +7818,7 @@ "source": [ "#### Formatting Using the Microsoft .NET Framework\n", "\n", - "Dyalog APL has an interface to Microsoft's .NET framework, which is introduced in [a later chapter](./Interfaces.ipynb).\n", + "Dyalog APL has an interface to Microsoft's .NET framework, which is introduced in [a later chapter](./System-Interfaces.ipynb).\n", "The .NET framework includes a vast collection of utility programs, including functions to interpret and format data according to rules defined for a given _locale_, or _culture_, or _language_ (which you can customise on your operating system).\n", "\n", "Let us start by declaring our intent to use the .NET framework:" diff --git a/docs/Nested-Arrays-Continued.ipynb b/docs/Nested-Arrays-Continued.ipynb index fc7bcfe..546c2d3 100644 --- a/docs/Nested-Arrays-Continued.ipynb +++ b/docs/Nested-Arrays-Continued.ipynb @@ -28,7 +28,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 3, "id": "pediatric-tender", "metadata": {}, "outputs": [], @@ -39,7 +39,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 4, "id": "normal-packet", "metadata": {}, "outputs": [ @@ -55,7 +55,7 @@ "" ] }, - "execution_count": 30, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -67,7 +67,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 5, "id": "maritime-minister", "metadata": {}, "outputs": [ @@ -86,7 +86,7 @@ "" ] }, - "execution_count": 31, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -119,7 +119,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 6, "id": "transsexual-receptor", "metadata": {}, "outputs": [ @@ -131,7 +131,7 @@ "" ] }, - "execution_count": 32, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -150,7 +150,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 7, "id": "radio-clinic", "metadata": {}, "outputs": [ @@ -196,7 +196,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 8, "id": "recorded-willow", "metadata": {}, "outputs": [ @@ -211,7 +211,7 @@ "" ] }, - "execution_count": 34, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -233,7 +233,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 9, "id": "exterior-salem", "metadata": {}, "outputs": [ @@ -262,7 +262,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 10, "id": "distant-combat", "metadata": {}, "outputs": [], @@ -280,7 +280,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 11, "id": "generic-gossip", "metadata": {}, "outputs": [ @@ -299,7 +299,7 @@ "" ] }, - "execution_count": 37, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -329,7 +329,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 12, "id": "strong-mirror", "metadata": {}, "outputs": [ @@ -343,7 +343,7 @@ "" ] }, - "execution_count": 38, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -354,7 +354,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 13, "id": "geological-spider", "metadata": {}, "outputs": [ @@ -365,7 +365,7 @@ "" ] }, - "execution_count": 39, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -385,7 +385,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 14, "id": "artificial-fetish", "metadata": {}, "outputs": [ @@ -396,7 +396,7 @@ "" ] }, - "execution_count": 40, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -419,7 +419,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 15, "id": "broadband-purple", "metadata": {}, "outputs": [ @@ -430,7 +430,7 @@ "" ] }, - "execution_count": 41, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -449,7 +449,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 16, "id": "egyptian-program", "metadata": {}, "outputs": [ @@ -460,7 +460,7 @@ "" ] }, - "execution_count": 42, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -481,7 +481,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 17, "id": "toxic-movement", "metadata": {}, "outputs": [ @@ -495,7 +495,7 @@ "" ] }, - "execution_count": 43, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -514,7 +514,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 18, "id": "analyzed-testament", "metadata": {}, "outputs": [ @@ -525,7 +525,7 @@ "" ] }, - "execution_count": 44, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -546,7 +546,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 19, "id": "mighty-privacy", "metadata": {}, "outputs": [ @@ -557,7 +557,7 @@ "" ] }, - "execution_count": 45, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -620,7 +620,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 20, "id": "amino-debate", "metadata": {}, "outputs": [], @@ -632,7 +632,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 21, "id": "latter-sacrifice", "metadata": {}, "outputs": [], @@ -650,7 +650,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 22, "id": "excellent-surgery", "metadata": {}, "outputs": [], @@ -669,7 +669,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 23, "id": "related-helping", "metadata": {}, "outputs": [ @@ -680,7 +680,7 @@ "" ] }, - "execution_count": 49, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -701,7 +701,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 24, "id": "related-spread", "metadata": {}, "outputs": [ @@ -717,7 +717,7 @@ "" ] }, - "execution_count": 50, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -740,7 +740,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 25, "id": "floating-lecture", "metadata": { "scrolled": false @@ -759,7 +759,7 @@ "" ] }, - "execution_count": 51, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -771,7 +771,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 46, "id": "unique-pipeline", "metadata": { "scrolled": true @@ -790,7 +790,7 @@ "" ] }, - "execution_count": 52, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" } @@ -800,6 +800,472 @@ "]display nesVec" ] }, + { + "cell_type": "markdown", + "id": "hired-renaissance", + "metadata": {}, + "source": [ + "Now, we revert back to the original values because we will need `nesVec` below:" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "id": "scientific-capture", + "metadata": {}, + "outputs": [], + "source": [ + "nesVec[1 5 6] ← 'Yes' 987 'Hello'" + ] + }, + { + "cell_type": "markdown", + "id": "bridal-fifth", + "metadata": {}, + "source": [ + "### More about DISPLAY\n", + "\n", + "Most of the time, the user command `]box` displays enough information when working with nested arrays in the session.\n", + "However, in some situations, you might want or need more granular display information, which you can obtain by using the function `DISPLAY`.\n", + "We have already seen the function `DISPLAY` and its main characteristics in [a previous section](./Data-and-Variables.ipynb#DISPLAY).\n", + "We now need to explore some additional characteristics of it." + ] + }, + { + "cell_type": "markdown", + "id": "powered-adaptation", + "metadata": {}, + "source": [ + "#### Conventions\n", + "\n", + "The following conventions are used in the character matrix that `DISPLAY` returns:\n", + "\n", + " - A simple scalar has no box around it.\n", + " - All other arrays are shown with a surrounding box.\n", + " The upper-left hand corner of the box describes the _shape_ of the array.\n", + " It can be:\n", + " - `─`, a simple line for a scalar that is an enclosed array;\n", + " - `→`, a single arrow, for a vector;\n", + " - `↓` or `↓↓`, one or more vertical arrows for matrices and higher-rank arrays;\n", + " - `⊖`, a horizontal circled minus for an array with empty last axis; or\n", + " - `⌽`, a vertical circled bar for an array with another empty axis.\n", + " - The bottom-left hand corner of the box describes the nature of the array:\n", + " - `─`, a simple line for character contents;\n", + " - `~`, a tilde for numeric contents;\n", + " - `+`, a _plus_ symbol for mixed contents;\n", + " - `∊`, a _membership_ symbol for nested arrays;\n", + " - `∇`, a _del_ for `⎕OR` arrays; or\n", + " - `#`, a hash for _namespace_ references.\n", + "\n", + "We have not yet studied the last two concepts (`⎕OR` and namespaces); you can ignore them for now." + ] + }, + { + "cell_type": "markdown", + "id": "beginning-intention", + "metadata": {}, + "source": [ + "#### Change the Default Presentation\n", + "\n", + "By default, the boxes are drawn with special line-drawing characters, but you can provide a zero left argument to force the function to use alternative (standard APL) characters:" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "aquatic-authentication", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "C:\\Program Files\\Dyalog\\Dyalog APL-64 18.2 Unicode\\ws\\DISPLAY.dws saved Thu Apr 7 00:29:10 2022\n", + "" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + ")copy DISPLAY" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "material-concrete", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "┌→────┐\n", + "│Hello│\n", + "└─────┘\n", + "" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "DISPLAY 'Hello'" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "id": "qualified-morris", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + ".→----.\n", + "|Hello|\n", + "'-----'\n", + "" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "0 DISPLAY 'Hello'" + ] + }, + { + "cell_type": "markdown", + "id": "thorough-marker", + "metadata": {}, + "source": [ + "As mentioned previously, the default presentation looks a lot better on the screen, but there may be situations where using standard APL characters may be preferred." + ] + }, + { + "cell_type": "markdown", + "id": "novel-blanket", + "metadata": {}, + "source": [ + "#### Distinguish Between Items\n", + "\n", + "Now that we have discovered the existence of scalars which are enclosed arrays, we can use `DISPLAY` to distinguish between the two kinds of scalars.\n", + "\n", + "Notice how `DISPLAY` does not draw a box around the 34 below:" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "id": "meaning-boulder", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + " \n", + "34\n", + " \n", + "" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "DISPLAY 34" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "id": "spatial-justice", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "┌─────────┐\n", + "│ ┌→────┐ │\n", + "│ │Hello│ │\n", + "│ └─────┘ │\n", + "└∊────────┘\n", + "" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "DISPLAY nesVec[6]" + ] + }, + { + "cell_type": "markdown", + "id": "industrial-proportion", + "metadata": {}, + "source": [ + "The sixth item of `nesVec` is an enclosed vector, so its corners are marked with a simple line and an `∊`.\n", + "It contains a second box whose corners tell us that `'Hello'` is a character vector.\n", + "`nesVec[6]` is a scalar containing a vector.\n", + "If we _disclose_ the item, we obtain a simple vector:" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "id": "dense-capital", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "┌→────┐\n", + "│Hello│\n", + "└─────┘\n", + "" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "DISPLAY ⊃nesVec[6]" + ] + }, + { + "cell_type": "markdown", + "id": "opposed-massage", + "metadata": {}, + "source": [ + "#### Empty Arrays\n", + "\n", + "Here is how `DISPLAY` identifies some empty arrays:\n", + "\n", + " - Empty numeric vector:" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "id": "statistical-worry", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "┌⊖┐\n", + "│0│\n", + "└~┘\n", + "" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "DISPLAY ⍬" + ] + }, + { + "cell_type": "markdown", + "id": "played-seventh", + "metadata": {}, + "source": [ + " - Empty text vector:" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "id": "structural-communist", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "┌⊖┐\n", + "│ │\n", + "└─┘\n", + "" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "DISPLAY ''" + ] + }, + { + "cell_type": "markdown", + "id": "treated-maker", + "metadata": {}, + "source": [ + "These are vectors, because there is not vertical arrow, and the `⊖` sign indicates that they are empty.\n", + "At the bottom of the boxes, the symbols `~` and `─` show that an empty numeric vector and an empty character vector are different.\n", + "One contains a zero, the other contains a blank.\n", + "This indicates the type of the array, which is a property of an array even when the array is empty (in [a later section](#Type,-Prototype,-Fill-Item) we talk more about _fill_ items).\n", + "\n", + "We can see the same kind of output for empty matrices:\n", + "\n", + " - Empty numeric matrix:" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "id": "spread-least", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "┌→────────┐\n", + "⌽0 0 0 0 0│\n", + "└~────────┘\n", + "" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "DISPLAY 0 5⍴0" + ] + }, + { + "cell_type": "markdown", + "id": "forbidden-murder", + "metadata": {}, + "source": [ + " - Empty character matrix:" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "id": "gentle-forum", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "┌→─────────┐\n", + "⌽ │\n", + "└──────────┘\n", + "" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "DISPLAY 0 10⍴''" + ] + }, + { + "cell_type": "markdown", + "id": "residential-audio", + "metadata": {}, + "source": [ + " - Another empty character matrix:" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "id": "concrete-fundamental", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "┌⊖┐\n", + "↓ │\n", + "│ │\n", + "│ │\n", + "│ │\n", + "│ │\n", + "└─┘\n", + "" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "DISPLAY 5 0⍴''" + ] + }, + { + "cell_type": "markdown", + "id": "inside-baghdad", + "metadata": {}, + "source": [ + " - Empty numeric 3D array:" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "id": "statistical-entertainment", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "┌┌⊖┐\n", + "↓↓0│\n", + "││0│\n", + "││0│\n", + "││ │\n", + "││0│\n", + "││0│\n", + "││0│\n", + "└└~┘\n", + "" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "DISPLAY 2 3 0⍴0" + ] + }, + { + "cell_type": "markdown", + "id": "rental-vampire", + "metadata": {}, + "source": [ + "The output for the empty numeric 3D array contains 2 sets of 3 zeroes to show that its shape is `2 3 0`." + ] + }, { "cell_type": "markdown", "id": "potential-domain", @@ -4635,7 +5101,7 @@ "Note that the two new vectors (`newtex` and `newnum`) are not identical to the original ones (`vtex` and `vnum`) because, when they were converted into the matrices `rtex` and `rnum`, the shorter items were padded.\n", "When one splits a matrix, the items of the result all have the same size.\n", "\n", - "#### Mix applied to heterogeneous data\n", + "#### Mix Applied to Heterogeneous Data\n", "\n", "The examples shown above represent very common uses of _mix_ and _split_.\n", "However, it is of course also possible to apply the functions to heterogeneous data.\n", @@ -12275,7 +12741,7 @@ "width": "360px" }, "toc_section_display": true, - "toc_window_display": true + "toc_window_display": false } }, "nbformat": 4,