{"id":6866,"date":"2021-07-19T13:02:32","date_gmt":"2021-07-19T13:02:32","guid":{"rendered":"https:\/\/www.dyalog.com\/blog\/?p=6866"},"modified":"2021-07-19T13:06:22","modified_gmt":"2021-07-19T13:06:22","slug":"code-golf-generating-empty-arrays","status":"publish","type":"post","link":"https:\/\/www.dyalog.com\/blog\/2021\/07\/code-golf-generating-empty-arrays\/","title":{"rendered":"Code Golf: Generating Empty Arrays"},"content":{"rendered":"<p><em>By: <a href=\"https:\/\/apl.wiki\/User:Xpqz\">Stefan Kruger<\/a><\/em><\/p>\n<p>Recently, I was looking for a Dyalog problem to pit my wits against, and I asked in the <a href=\"https:\/\/apl.chat\" target=\"_blank\" rel=\"noopener\">APL Orchard<\/a> if Ad\u00e1m could make one up:<\/p>\n<div style=\"padding-left: 2em\">\n<p><a href=\"https:\/\/chat.stackexchange.com\/transcript\/message\/58543938#58543938\" target=\"_blank\" rel=\"noopener\">@Ad\u00e1m Any CMCs today?<\/a><\/p>\n<\/div>\n<p>A <em>CMC<\/em>, if you&#8217;re unfamiliar with the APL Orchard, is a <em>Chat Mini Challenge<\/em> \u2013 typically an informal <a href=\"https:\/\/apl.wiki\/code golf\" target=\"_blank\" rel=\"noopener\">code golf<\/a> challenge to produce the shortest possible bit of code that solves the set problem. Code golf practitioners usually delve into the dustiest corners of a language and, if practiced diligently, this can lead to a deep mastery over time, even if some <s>dirty hacks<\/s> techniques employed may be frowned upon in production code.<\/p>\n<p>Anyway. Ad\u00e1m responded with the following:<\/p>\n<div style=\"padding-left: 2em\"><a href=\"https:\/\/chat.stackexchange.com\/transcript\/message\/58544181#58544181\" target=\"_blank\" rel=\"noopener\">@xpqz <strong>CMC:<\/strong> Produce <code>0 0\u23740<\/code><\/a><\/div>\n<h2>The Mysterious Case of <code class=\"language-apl\" style=\"font-size: unset!important\">0 0\u23740<\/code><\/h2>\n<p>Hmm. What even <em>is<\/em> that thing\u203d It&#8217;s only 5 characters already \u2013 not much scope to shrink that, surely? Let&#8217;s have a look at it with full boxing:<\/p>\n<pre><code class=\"language-apl\">      \u2395IO\u21900\r\n      ]Box on -style=max\r\n\u250c\u2192\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502Was ON -style=max\u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n      0 0\u23740\r\n\u250c\u2296\u2510\r\n\u233d0\u2502\r\n\u2514~\u2518\r\n<\/code><\/pre>\n<p>In the boxed output, the <code class=\"language-apl\">\u233d<\/code> tells us that the leading axis has length 0, the <code class=\"language-apl\">\u2296<\/code> means that the trailing axis has length 0, and the <code class=\"language-apl\">~<\/code> means that the array is non-nested.<\/p>\n<p>This is a simple numeric array of two dimensions, each of length 0 \u2013 think of it as a spreadsheet or table before you&#8217;ve put any rows or columns of data in it.<\/p>\n<p>I found this problem difficult to get started with, so I <a href=\"https:\/\/aplcart.info?q=0%200%E2%8D%B40\" target=\"_blank\" rel=\"noopener\">searched for the expression on APL Cart<\/a>, and discovered that:<\/p>\n<pre><code class=\"language-apl\">      ]Box off\r\nWas ON\r\n      ]APLCart 0 0\u23740   \u235d Dyalog 18.1 has APLCart built in! Fancy.\r\nX,Y,Z:any M,N:num I,J:int A,B:Bool C,D:char f,g,h:fn ax:axis s:scal v:vec m:mat\r\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\r\n\u236c\u22a4\u236c  zero-by-zero numeric matrix                                               \r\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\r\nShowing 1 of 1 matches                                                         \r\n      ]Box on\r\n\u250c\u2192\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502Was OFF\u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>Surely not? Let&#8217;s try that suggestion:<\/p>\n<pre><code class=\"language-apl\">      (0 0\u23740)\u2261\u236c\u22a4\u236c\r\n1\r\n<\/code><\/pre>\n<p>Well, it clearly works, but <em>why<\/em>? Let&#8217;s see if we can figure that one out.<\/p>\n<p>In the basic case for <em>encode<\/em>, <code class=\"language-apl\">X\u22a4Y<\/code>, if <code class=\"language-apl\">X<\/code> and <code class=\"language-apl\">Y<\/code> are vectors, the result will have one column for each element in <code class=\"language-apl\">Y<\/code> and one row for each element in <code class=\"language-apl\">X<\/code>. Using the example from the language bar:<\/p>\n<pre><code class=\"language-apl\">      2 2 2 2 \u22a4 5 7 12 \u235d Convert decimal to binary\r\n\u250c\u2192\u2500\u2500\u2500\u2500\u2510\r\n\u21930 0 1\u2502\r\n\u25021 1 1\u2502\r\n\u25020 1 0\u2502\r\n\u25021 1 0\u2502\r\n\u2514~\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>we have a shape of <code class=\"language-apl\">4 3<\/code>, as the length of the vector to the left (<code class=\"language-apl\">2 2 2 2<\/code>) is 4 and the length of the vector to the right (<code class=\"language-apl\">5 7 12<\/code>) is 3.<\/p>\n<p>Returning to <code class=\"language-apl\">\u236c\u22a4\u236c<\/code>, given the above, we can deduce that the result should have a rank of 2 with a shape of <code class=\"language-apl\">0 0<\/code> which, of course, is what we wanted to achieve:<\/p>\n<pre><code class=\"language-apl\">      \u2374\u236c\u22a4\u236c \u235d Shape 0 0\r\n\u250c\u2192\u2500\u2500\u2510\r\n\u25020 0\u2502\r\n\u2514~\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>Disappointingly, I had to cheat by looking up the answer. However, are there any more length-3 solutions? Apparently, <code class=\"language-apl\">\u236c\u22a4\u236c<\/code> is &#8220;reasonably well known&#8221;. I decided to write a simple brute-force search function to look for any other solutions.<\/p>\n<p>This works as follows:<\/p>\n<ol>\n<li>Create all possible length-3 combinations of APL glyphs<\/li>\n<li>Evaluate each in turn, skipping those that error<\/li>\n<li>Save those that evaluate to <code class=\"language-apl\">0 0\u23740<\/code><\/li>\n<\/ol>\n<p>Here&#8217;s what I ended up with:<\/p>\n<pre><code class=\"language-apl\">\u2207 r\u2190Bruter target;glyphs;combo;eval \r\n  glyphs \u2190 '0\u236c+-\u00d7\u00f7*\u235f\u2339\u25cb|\u2308\u230a\u22a5\u22a4\u22a3\u22a2=\u2260\u2264&lt;&gt;\u2265\u2261\u2262\u2228\u2227\u2372\u2371\u2191\u2193\u2282\u2283\u2286\u2337\u234b\u2352\u2373\u2378\u220a\u2377\u222a\u2229~\/\\\u233f\u2340,\u236a\u2374\u233d\u2296\u2349\u00a8\u2368\u2363.\u2218\u2364\u2365@\u2338\u233a\u234e\u2355\u00af'\r\n  r \u2190 \u236c\r\n  :For combo :In ,\u2218.,\u23632\u2368glyphs\r\n      :Trap 0\r\n          eval \u2190 \u234ecombo\r\n      :Else\r\n          :Continue\r\n      :EndTrap\r\n      :If eval\u2261target\r\n          r ,\u2190 \u2282combo\r\n      :EndIf\r\n  :EndFor\r\n\u2207\r\n<\/code><\/pre>\n<p>I decided to leave out a few glyphs that I guessed would be unlikely to feature (<code class=\"language-apl\">\u2190\u2192\u2395\u2360\u235e\u235d\u22c4<\/code>), and I only added the number 0. Let&#8217;s see what that generates:<\/p>\n<pre><code class=\"language-apl\">      7 5\u2374Bruter 0 0\u23740 \u235d\u00a07\u00d75 layout added for clarity after the fact\r\n\u250c\u2192\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2193 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u236c\u22a4\u236c\u2502 \u2502+\u2338\u236c\u2502 \u2502-\u2338\u236c\u2502 \u2502\u00d7\u2338\u236c\u2502 \u2502\u00f7\u2338\u236c\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502*\u2338\u236c\u2502 \u2502\u235f\u2338\u236c\u2502 \u2502\u25cb\u2338\u236c\u2502 \u2502|\u2338\u236c\u2502 \u2502\u2308\u2338\u236c\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u230a\u2338\u236c\u2502 \u2502\u22a4\u2368\u236c\u2502 \u2502\u22a4\u2338\u236c\u2502 \u2502\u22a2\u2338\u236c\u2502 \u2502=\u2338\u236c\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u2260\u2338\u236c\u2502 \u2502\u2264\u2338\u236c\u2502 \u2502&lt;\u2338\u236c\u2502 \u2502&gt;\u2338\u236c\u2502 \u2502\u2265\u2338\u236c\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u2228\u2338\u236c\u2502 \u2502\u2227\u2338\u236c\u2502 \u2502\u2372\u2338\u236c\u2502 \u2502\u2371\u2338\u236c\u2502 \u2502\u2191\u23780\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u2191\u2338\u236c\u2502 \u2502\u2193\u2338\u236c\u2502 \u2502\u2377\u2338\u236c\u2502 \u2502\u2229\u2338\u236c\u2502 \u2502\/\u2338\u236c\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u233f\u2338\u236c\u2502 \u2502\u2374\u2338\u236c\u2502 \u2502\u233d\u2338\u236c\u2502 \u2502\u2296\u2338\u236c\u2502 \u2502\u2349\u2338\u236c\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2514\u220a\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>Wow! There are <em>35<\/em> of them (for <code class=\"language-apl\">\u2395IO\u21900<\/code>)!<\/p>\n<p>There are clearly patterns here \u2013 we can see our friend <code class=\"language-apl\">\u236c\u22a4\u236c<\/code> right at the beginning, and also its equivalent <code class=\"language-apl\">\u22a4\u2368\u236c<\/code>. We can also see <code class=\"language-apl\">\u2191\u23780<\/code> which, in retrospect, perhaps I should have thought of in the first place.<\/p>\n<p>The remaining 32 solutions all feature <em>key<\/em>. The majority of those have a scalar function operand; we can treat this whole group as equivalent. Let&#8217;s tackle that group first, with the operand <code class=\"language-apl\">+<\/code> as the example:<\/p>\n<pre><code class=\"language-apl\">      +\u2338\u236c\r\n\u250c\u2296\u2510\r\n\u233d0\u2502\r\n\u2514~\u2518\r\n<\/code><\/pre>\n<p>Let&#8217;s recap what <em>key<\/em> does. The operand dyadic function is called with each unique element of the argument in turn as its left argument, and a vector of indices of occurrences as its right. <em>Key<\/em> then returns a rank 2 array of the results. For example:<\/p>\n<pre><code class=\"language-apl\">      {\u237a \u2375}\u2338'Mississippi'\r\n\u250c\u2192\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2193   \u250c\u2192\u2510        \u2502\r\n\u2502 M \u25021\u2502        \u2502\r\n\u2502 - \u2514~\u2518        \u2502\r\n\u2502   \u250c\u2192\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u2502\r\n\u2502 i \u25022 5 8 11\u2502 \u2502\r\n\u2502 - \u2514~\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2502\r\n\u2502   \u250c\u2192\u2500\u2500\u2500\u2500\u2500\u2500\u2510  \u2502\r\n\u2502 s \u25023 4 6 7\u2502  \u2502\r\n\u2502 - \u2514~\u2500\u2500\u2500\u2500\u2500\u2500\u2518  \u2502\r\n\u2502   \u250c\u2192\u2500\u2500\u2500\u2510     \u2502\r\n\u2502 p \u25029 10\u2502     \u2502\r\n\u2502 - \u2514~\u2500\u2500\u2500\u2518     \u2502\r\n\u2514\u220a\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>With an argument of the empty vector <code class=\"language-apl\">\u236c<\/code>, in the operand function, <code class=\"language-apl\">\u237a<\/code> will always be <code class=\"language-apl\">0<\/code> \u2013 the prototype element of our empty numeric vector:<\/p>\n<pre><code class=\"language-apl\">      {\u2395\u2190\u237a}\u2338\u236c\r\n0\r\n<\/code><\/pre>\n<p>What about <code class=\"language-apl\">\u2375<\/code>? Well, it must be an empty numeric vector (no found indices):<\/p>\n<pre><code class=\"language-apl\">      {\u2395\u2190\u2375}\u2338\u236c\r\n\u250c\u2296\u2510\r\n\u25020\u2502\r\n\u2514~\u2518\r\n<\/code><\/pre>\n<p>So, with a scalar function like <code class=\"language-apl\">+<\/code> as the operand, we end up with <code class=\"language-apl\">0+\u236c<\/code>. <em>Key<\/em> returns an array where each major cell is the result of the function applied to the unique element and its indices, which in this case is an array with major cells of the structure <code class=\"language-apl\">\u236c<\/code>. How many such major cells? 0. So the result is <code class=\"language-apl\">0\u233f1 0\u2374\u236c<\/code>, which is, of course, <code class=\"language-apl\">0 0\u23740<\/code>.<\/p>\n<p>So for <code class=\"language-apl\">0 f \u236c<\/code> for any scalar dyadic function <code class=\"language-APL\">f<\/code>, the above holds. For example:<\/p>\n<pre><code class=\"language-apl\">      0&gt;\u236c\r\n\u250c\u2296\u2510\r\n\u25020\u2502\r\n\u2514~\u2518\r\n      &gt;\u2338\u236c\r\n\u250c\u2296\u2510\r\n\u233d0\u2502\r\n\u2514~\u2518\r\n<\/code><\/pre>\n<p>Then we have a lot of non-scalar operands, like <code class=\"language-apl\">\u2296\/\u2377\u2191\u2193<\/code>. All we need to understand is why they produce <code class=\"language-apl\">\u236c<\/code> when applied as <code class=\"language-apl\">0 f \u236c<\/code>, as <em>key<\/em> will call them. Some of these are pretty obvious, like <em>find<\/em>, <code class=\"language-apl\">\u2377<\/code>:<\/p>\n<pre><code class=\"language-apl\">      0\u2377\u236c \u235d Find all locations of 0 in the empty vector\r\n\u250c\u2296\u2510\r\n\u25020\u2502\r\n\u2514~\u2518\r\n<\/code><\/pre>\n<p>or <em>take<\/em> and <em>drop<\/em>, <code class=\"language-apl\">\u2191\u2193<\/code>:<\/p>\n<pre><code class=\"language-apl\">      0\u2191\u236c \u235d Take no elements from the beginning of the empty vector\r\n\u250c\u2296\u2510\r\n\u25020\u2502\r\n\u2514~\u2518\r\n      0\u2193\u236c \u235d Drop no elements from the end of the empty vector\r\n\u250c\u2296\u2510\r\n\u25020\u2502\r\n\u2514~\u2518\r\n<\/code><\/pre>\n<p>However, <code class=\"language-apl\">\u2349<\/code> gives us a dyadic transpose \u2013 and, perhaps unexpectedly, this one is <code class=\"language-apl\">\u2395IO<\/code>-dependent:<\/p>\n<pre><code class=\"language-apl\">      0\u2349\u236c\r\n\u250c\u2296\u2510\r\n\u25020\u2502\r\n\u2514~\u2518\r\n<\/code><\/pre>\n<p>At first glance, this made no sense to me. The reason this works is that transposing a vector is an identity operation:<\/p>\n<pre><code class=\"language-apl\">      \u2349'Transposing a vector returns the vector'\r\n\u250c\u2192\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502Transposing a vector returns the vector\u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>A vector has a single axis, so &#8220;reordering the axes&#8221; doesn&#8217;t do anything. The same holds true for the dyadic form, assuming the left argument is <code class=\"language-APL\">\u2395IO<\/code>:<\/p>\n<pre><code class=\"language-apl\">      0\u2349'Same for the dyadic form. Sometimes.'\r\n\u250c\u2192\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502Same for the dyadic form. Sometimes.\u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>This is the reason why this only works for <code class=\"language-apl\">\u2395IO\u21900<\/code>: <em>Key<\/em> always provides 0 for the left argument. For <code class=\"language-apl\">\u2395IO\u21901<\/code> we will get a <code class=\"language-APL\">DOMAIN ERROR<\/code>:<\/p>\n<pre><code class=\"language-apl\">      \u2395IO\u21901\r\n      0\u2349'Same for the dyadic form. Sometimes.'\r\nDOMAIN ERROR\r\n      0\u2349'Same for the dyadic form. Sometimes.'\r\n       \u2227\r\n<\/code><\/pre>\n<p>A few others stand out. <em>Replicate<\/em> (and its sibling <em>replicate-first<\/em>), for example:<\/p>\n<pre><code class=\"language-apl\">      \/\u2338\u236c\r\n\u250c\u2296\u2510\r\n\u233d0\u2502\r\n\u2514~\u2518\r\n<\/code><\/pre>\n<p>will end up as:<\/p>\n<pre><code class=\"language-apl\">      0\/\u236c \u235d zero empty vectors\r\n\u250c\u2296\u2510\r\n\u25020\u2502\r\n\u2514~\u2518\r\n<\/code><\/pre>\n<p>in the left operand \u2013 zero empty vectors is still the empty vector. <em>Reshape<\/em> is similar:<\/p>\n<pre><code class=\"language-apl\">      0\u2374\u236c \u235d\u00a0zero empty vectors\r\n\u250c\u2296\u2510\r\n\u25020\u2502\r\n\u2514~\u2518\r\n<\/code><\/pre>\n<p><em>Encode<\/em> tries to express <code class=\"language-apl\">\u236c<\/code> in the 0 radix; also an empty vector:<\/p>\n<pre><code class=\"language-apl\">      0\u22a4\u236c\r\n\u250c\u2296\u2510\r\n\u25020\u2502\r\n\u2514~\u2518\r\n<\/code><\/pre>\n<p>My favourite, though, is probably <code class=\"language-apl\">\u2191\u23780<\/code>, and, as I said earlier, I&#8217;m a bit disappointed I didn&#8217;t find that before resorting to brute force and ignorance. <em>Where<\/em> (<code class=\"language-apl\">\u2378<\/code>) returns a vector of indices with 1 for its Boolean array right argument. If we call it with a right argument of 0, we&#8217;ll get an empty vector of empty numeric vectors. This is because the one (and only) valid index into a scalar is the empty vector, and none of them (!) are non-zero.<\/p>\n<pre><code class=\"language-apl\">      \u23780\r\n\u250c\u2296\u2500\u2500\u2500\u2500\u2510\r\n\u2502 \u250c\u2296\u2510 \u2502\r\n\u2502 \u25020\u2502 \u2502\r\n\u2502 \u2514~\u2518 \u2502\r\n\u2514\u220a\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>Trading depth for rank, we get the shape we want:<\/p>\n<pre><code class=\"language-apl\">      \u2191\u23780\r\n\u250c\u2296\u2510\r\n\u233d0\u2502\r\n\u2514~\u2518\r\n<\/code><\/pre>\n<h2 id=\"what-about-0\u2374\u2282\u236c\">What About <code class=\"language-apl\" style=\"font-size: unset!important\">0\u2374\u2282\u236c<\/code>?<\/h2>\n<p>The expression <code class=\"language-apl\">\u23780<\/code> above is the only length-2 way to produce an empty vector of empty numeric vectors:<\/p>\n<pre><code class=\"language-apl\">      (\u23780)\u22610\u2374\u2282\u236c\r\n1\r\n<\/code><\/pre>\n<p>However, there are several interesting length-3 solutions. Deploying the <code class=\"language-apl\">Bruter<\/code> again:<\/p>\n<pre><code class=\"language-apl\">      8 7\u2374res\u2190Bruter 0\u2374\u2282\u236c\r\n\u250c\u2192\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2193 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u25020\u22820\u2502 \u25020\u2282\u236c\u2502 \u25020\u2286\u236c\u2502 \u2502\u236c\u22820\u2502 \u2502\u236c\u2282\u236c\u2502 \u2502\u236c\u2286\u236c\u2502 \u2502+\u23780\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502-\u23780\u2502 \u2502\u00d7\u23780\u2502 \u2502\u00f7\u23780\u2502 \u2502*\u23780\u2502 \u2502\u235f\u23780\u2502 \u2502\u25cb\u23780\u2502 \u2502|\u23780\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u2308\u23780\u2502 \u2502\u230a\u23780\u2502 \u2502\u22a3\u23780\u2502 \u2502\u22a2\u23780\u2502 \u2502\u2282\u23680\u2502 \u2502\u2282\u2368\u236c\u2502 \u2502\u2286\u23780\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u2286\u2368\u236c\u2502 \u2502\u2337\u23780\u2502 \u2502\u2373\u00a8\u236c\u2502 \u2502\u237800\u2502 \u2502\u23780.\u2502 \u2502\u2378+0\u2502 \u2502\u2378-0\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u2378\u00d70\u2502 \u2502\u2378\u25cb0\u2502 \u2502\u2378|0\u2502 \u2502\u2378\u23080\u2502 \u2502\u2378\u230a0\u2502 \u2502\u2378\u22a30\u2502 \u2502\u2378\u22a20\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u2378\u22610\u2502 \u2502\u2378\u2262\u236c\u2502 \u2502\u2378\u21910\u2502 \u2502\u2378\u21930\u2502 \u2502\u2378\u22820\u2502 \u2502\u2378\u22830\u2502 \u2502\u2378\u2283\u236c\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u2378\u22860\u2502 \u2502\u2378\u23370\u2502 \u2502\u2378\u233d0\u2502 \u2502\u2378\u22960\u2502 \u2502\u2378\u23490\u2502 \u2502\u2378.0\u2502 \u2502\u2378\u00af0\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u222a\u23780\u2502 \u2502~\u23780\u2502 \u2502,\u23780\u2502 \u2502\u2374\u00a8\u236c\u2502 \u2502\u233d\u23780\u2502 \u2502\u2296\u23780\u2502 \u2502\u2349\u23780\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2514\u220a\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>Most are <code class=\"language-apl\">\u23780<\/code> combined with an additional primitive that has no effect, or selfie-mirrors, so let&#8217;s restrict ourselves to the interesting subset:<\/p>\n<pre><code class=\"language-apl\">      4 2\u2374res\/\u2368~'\u2378\u2368'\u2218(\u2228\/\u220a)\u00a8res \u235d\u00a0Skip variants of \u23780 and selfies\r\n\u250c\u2192\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2193 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u25020\u22820\u2502 \u25020\u2282\u236c\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u25020\u2286\u236c\u2502 \u2502\u236c\u22820\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u236c\u2282\u236c\u2502 \u2502\u236c\u2286\u236c\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2502 \u250c\u2192\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502\u2373\u00a8\u236c\u2502 \u2502\u2374\u00a8\u236c\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2518 \u2502\r\n\u2514\u220a\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>We can see a few patterns again \u2013 <em>partition<\/em> (<code class=\"language-apl\">\u2286<\/code>) or <em>partitioned enclose<\/em> (<code class=\"language-apl\">\u2282<\/code>), with 0 as left or right argument and <code class=\"language-apl\">\u236c<\/code> as left or right argument, plus two variants using <em>each<\/em> (<code class=\"language-apl\">\u00a8<\/code>) on <code class=\"language-apl\">\u236c<\/code>. Let&#8217;s look at <code class=\"language-apl\">\u2282<\/code> first.<\/p>\n<p><em>Partitioned enclose<\/em> groups, or <em>partitions<\/em>, stretches its right argument as specified by its Boolean vector left argument, with each new partition starting on 1, and returns a nested vector of the resulting partitions:<\/p>\n<pre><code class=\"language-apl\">      1 0 0 0 0 1 1 0 0 0 0\u2282'Hello World'\r\n\u250c\u2192\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502 \u250c\u2192\u2500\u2500\u2500\u2500\u2510 \u250c\u2192\u2510 \u250c\u2192\u2500\u2500\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502Hello\u2502 \u2502 \u2502 \u2502World\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2518 \u2514\u2500\u2500\u2500\u2500\u2500\u2518 \u2502\r\n\u2514\u220a\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>In the first case, <code class=\"language-apl\">0\u22820<\/code>, we&#8217;re saying that we want 0 partitions of 0 (which gets treated as a 1-element vector), returned as a nested vector \u2013 in other words, exactly the &#8220;empty vector of empty numeric vectors&#8221; that we&#8217;re after. In fact, <code class=\"language-apl\">\u2282<\/code> with a 0 as its left argument returns an empty vector of empty vectors of the prototype element of the right, which also helps to explain our <code class=\"language-apl\">0\u2282\u236c<\/code>:<\/p>\n<pre><code class=\"language-apl\">      0\u2282'hello world' \u235d Empty vector of empty character vectors\r\n\u250c\u2296\u2500\u2500\u2500\u2500\u2510\r\n\u2502 \u250c\u2296\u2510 \u2502\r\n\u2502 \u2502 \u2502 \u2502\r\n\u2502 \u2514\u2500\u2518 \u2502\r\n\u2514\u220a\u2500\u2500\u2500\u2500\u2518\r\n      0\u22821 2 3 4 5 \u235d Empty vector of empty numeric vectors\r\n\u250c\u2296\u2500\u2500\u2500\u2500\u2510\r\n\u2502 \u250c\u2296\u2510 \u2502\r\n\u2502 \u25020\u2502 \u2502\r\n\u2502 \u2514~\u2518 \u2502\r\n\u2514\u220a\u2500\u2500\u2500\u2500\u2518\r\n      0\u2282\u236c \u235d Empty vector of empty numeric vectors\r\n\u250c\u2296\u2500\u2500\u2500\u2500\u2510\r\n\u2502 \u250c\u2296\u2510 \u2502\r\n\u2502 \u25020\u2502 \u2502\r\n\u2502 \u2514~\u2518 \u2502\r\n\u2514\u220a\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>Swapping the order of that last expression:<\/p>\n<pre><code class=\"language-apl\">      \u236c\u22820\r\n\u250c\u2296\u2500\u2500\u2500\u2500\u2510\r\n\u2502 \u250c\u2296\u2510 \u2502\r\n\u2502 \u25020\u2502 \u2502\r\n\u2502 \u2514~\u2518 \u2502\r\n\u2514\u220a\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>is really the same thing: the left side is still a numeric vector with no 1s.<\/p>\n<p>What about <code class=\"language-apl\">\u2286<\/code>? If we restrict ourselves to a Boolean left argument again, <em>partition<\/em> is similar to <em>replicate<\/em>, but instead of just skipping elements of the right side corresponding to 0s in the left side, it <em>encloses<\/em> groups of elements corresponding to 1s, and skips the rest:<\/p>\n<pre><code class=\"language-apl\">      1 1 1 1 1 0 1 1 1 1 1\u2286'Hello World'\r\n\u250c\u2192\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502 \u250c\u2192\u2500\u2500\u2500\u2500\u2510 \u250c\u2192\u2500\u2500\u2500\u2500\u2510 \u2502\r\n\u2502 \u2502Hello\u2502 \u2502World\u2502 \u2502\r\n\u2502 \u2514\u2500\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2500\u2500\u2518 \u2502\r\n\u2514\u220a\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>Compare with <em>replicate<\/em>:<\/p>\n<pre><code class=\"language-apl\">      1 1 1 1 1 0 1 1 1 1 1\/'Hello World'\r\n\u250c\u2192\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502HelloWorld\u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>As with <code class=\"language-apl\">\u2282<\/code>, <code class=\"language-apl\">\u2286<\/code> returns a vector of vectors and, by the same reasoning, if the left argument contains no 1s, then the inner vector will be an empty vector of the prototype element of the right argument:<\/p>\n<pre><code class=\"language-apl\">      0\u22861 2 23 34 \r\n\u250c\u2296\u2500\u2500\u2500\u2500\u2510\r\n\u2502 \u250c\u2296\u2510 \u2502\r\n\u2502 \u25020\u2502 \u2502\r\n\u2502 \u2514~\u2518 \u2502\r\n\u2514\u220a\u2500\u2500\u2500\u2500\u2518\r\n<\/code><\/pre>\n<p>We should understand the remaining <code class=\"language-apl\">\u2286<\/code> variant, <code class=\"language-apl\">\u236c\u2286\u236c<\/code>, too. You might wonder why there is no <code class=\"language-apl\">0\u22860<\/code>, analogous to the <code class=\"language-apl\">0\u22820<\/code> we saw earlier; a fair question. However, it results in an error:<\/p>\n<pre><code class=\"language-apl\">      0\u22860 \u235d RANK ERROR\r\nRANK ERROR\r\n      0\u22860 \u235d RANK ERROR\r\n       \u2227\r\n<\/code><\/pre>\n<p>The reason for this is that <code class=\"language-apl\">\u2286<\/code> is IBM&#8217;s APL2 primitive, supplied for compatibility reasons. It simply doesn&#8217;t treat a scalar right argument as a 1-element vector, unlike <code class=\"language-apl\">\u2282<\/code>.<\/p>\n<p>What remains are the two variants using the <em>each<\/em> operator: <code class=\"language-apl\">\u2373\u00a8\u236c<\/code> and <code class=\"language-apl\">\u2374\u00a8\u236c<\/code>. <em>Each<\/em> always returns an array of the same shape as its right argument, in which each element is the result of applying the operand to the corresponding element in the argument.<\/p>\n<p>By that reasoning, with an argument of <code class=\"language-apl\">\u236c<\/code> we&#8217;ll always end up with an empty vector. The prototype element is itself a vector, as both <code class=\"language-apl\">\u2373<\/code> and <code class=\"language-apl\">\u2374<\/code> returns vectors \u2013 and, in our specific case, empty numeric vectors, as given the argument <code class=\"language-apl\">\u236c<\/code>.<\/p>\n<h2>Closing Remark<\/h2>\n<p>Many people \u2013 certainly including myself \u2013 find reasoning about the behaviour of <a href=\"https:\/\/apl.wiki\/empty array\">empty arrays<\/a> in Dyalog APL difficult. Going through exercises such as these can help to make this clearer.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By: Stefan Kruger Recently, I was looking for a Dyalog problem to pit my wits against, and I asked in the APL Orchard if Ad\u00e1m could make one up: @Ad\u00e1m Any CMCs today? A CMC, if you&#8217;re unfamiliar with the &hellip; <a href=\"https:\/\/www.dyalog.com\/blog\/2021\/07\/code-golf-generating-empty-arrays\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-6866","post","type-post","status-publish","format-standard","hentry","category-apl-language"],"_links":{"self":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/6866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/comments?post=6866"}],"version-history":[{"count":30,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/6866\/revisions"}],"predecessor-version":[{"id":6896,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/6866\/revisions\/6896"}],"wp:attachment":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/media?parent=6866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/categories?post=6866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/tags?post=6866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}