{"id":3321,"date":"2015-10-13T09:53:38","date_gmt":"2015-10-13T09:53:38","guid":{"rendered":"http:\/\/www.dyalog.com\/blog\/?p=3321"},"modified":"2015-10-13T10:07:58","modified_gmt":"2015-10-13T10:07:58","slug":"the-reflexcommute-operator","status":"publish","type":"post","link":"https:\/\/www.dyalog.com\/blog\/2015\/10\/the-reflexcommute-operator\/","title":{"rendered":"The Reflex\/Commute Operator"},"content":{"rendered":"<p>The monadic operator <code class=\"language-apl\">\u2368<\/code> is defined and modeled as follows:<\/p>\n<pre><code class=\"language-apl\">     f\u2368 \u2375  \u2190\u2192  \u2375 f \u2375\r\n   \u237a f\u2368 \u2375  \u2190\u2192  \u2375 f \u237a\r\n\r\n   {\u237a\u2190\u2375 \u22c4 \u2375 \u237a\u237a \u237a}\r\n<\/code><\/pre>\n<p><strong>Reflex<\/strong><\/p>\n<p>Some common well-known functions can be written as <code class=\"language-apl\">f\u2368<\/code> where <code class=\"language-apl\">f<\/code> is itself a well-known function:<\/p>\n<p><code class=\"language-apl\">\u00a0 \u00a0+\u2368 \u00a0 \u00a0<\/code>double<br \/>\n<code class=\"language-apl\">\u00a0 \u00a0\u00d7\u2368 \u00a0 \u00a0<\/code>square<br \/>\n<code class=\"language-apl\">\u00a0 \u00a0?\u2368 \u00a0 \u00a0<\/code>random permutation<br \/>\n<code class=\"language-apl\">\u00a0 \u00a0\u2373\u2368 \u00a0 \u00a0<\/code>self-index, <a href=\"http:\/\/archive.vector.org.uk\/art10501480\" target=\"_blank\">APL Amuse-Bouche 3<\/a><\/p>\n<p>See <a href=\"http:\/\/www.jsoftware.com\/jwiki\/Essays\/Reflexive\" target=\"_blank\">http:\/\/www.jsoftware.com\/jwiki\/Essays\/Reflexive<\/a> for further examples.<\/p>\n<p>Awareness of the importance of the reflexive case might have led us to avoid the mistake in the definition of the dyadic case of <code class=\"language-apl\">\u234b<\/code>. That is, if<\/p>\n<pre><code class=\"language-apl\">   \u237a\u234b\u2375 \u2190\u2192 \u237a\u2337\u2368\u2282\u234b\u2375\r\n<\/code><\/pre>\n<p>then <code class=\"language-apl\">\u234b\u2368\u2375<\/code> would be <em>sort<\/em>. Ken Iverson seemed to have had this awareness because that&#8217;s how he defined the dyadic case of <code class=\"language-apl\">\u234b<\/code> in J. (I say &#8220;seemed&#8221; because he <a href=\"http:\/\/keiapl.org\/anec\/#sort\" target=\"_blank\">expressed surprise<\/a> when first shown this use of <code class=\"language-apl\">\u234b\u2368<\/code>.)<\/p>\n<p>The monadic case <code class=\"language-apl\">f\u2368<\/code> came relatively late. It was not in <a href=\"http:\/\/www.jsoftware.com\/papers\/opfns.htm\" target=\"_blank\"><em>Operators and Functions<\/em><\/a> (1978) nor <a href=\"http:\/\/www.jsoftware.com\/papers\/RationalizedAPL.htm\" target=\"_blank\"><em>Rationalized APL<\/em><\/a> (1983), and only introduced in <a href=\"http:\/\/www.jsoftware.com\/papers\/APLDictionary.htm\" target=\"_blank\"><em>A Dictionary of APL<\/em><\/a> (1987). It came to Ken Iverson when he explicitly looked to natural languages for inspiration, whence it became &#8220;obvious&#8221;: <code class=\"language-apl\">f\u2368\u2375 \u2190\u2192 \u2375 f \u2375<\/code> is the reflexive voice (je m&#8217;appelle Roger) and <code class=\"language-apl\">\u237a f\u2368 \u2375 \u2190\u2192 \u2375 f \u237a<\/code> is the passive voice (the programming competition was won by a 17-year-old student <em>vs<\/em>. a 17-year-old student won the programming competition), both having evolved in natural languages for effective communication and elegant expression.<\/p>\n<p><strong>Commute<\/strong><\/p>\n<p>The alternative definition of <code class=\"language-apl\">\u237a\u234b\u2375<\/code> above, while illustrating the importance of the reflexive case (<code class=\"language-apl\">f\u2368 \u2375<\/code>), also illustrates the passive case (<code class=\"language-apl\">\u237a f\u2368 \u2375<\/code>). <code class=\"language-apl\">\u237a\u2337\u2368\u2282\u234b\u2375<\/code> can be read and understood as &#8220;<code class=\"language-apl\">\u237a<\/code> indexed by the enclosed grade of <code class=\"language-apl\">\u2375<\/code>&#8220;, a different (and in my mind a better) emphasis than <code class=\"language-apl\">(\u2282\u234b\u2375)\u2337\u237a<\/code>, &#8220;the enclosed grade of <code class=\"language-apl\">\u2375<\/code>, indexed into <code class=\"language-apl\">\u237a<\/code>&#8220;.<\/p>\n<p>I note that Arianna Locatelli, <a href=\"http:\/\/www.dyalog.com\/news\/102\/420\/2015-APL-Programming-Contest-Winners.htm\">winner of the 2015 APL Problem Solving Competition<\/a> but an APL beginner, used <code class=\"language-apl\">\u2368<\/code> twenty-one times in <a href=\"http:\/\/www.dyalog.com\/uploads\/conference\/dyalog15\/presentations\/U09b_How_I_Won_The_Competition.pdf\" target=\"_blank\">her presentation at Dyalog &#8217;15<\/a>. For example,<code class=\"language-apl\">\u2368<\/code> was used in the computation of the standard deviation (slide 13):<\/p>\n<pre><code class=\"language-apl\">   sol5\u2190{a\u2190,\u2375 \u22c4 \u22830.5*\u2368(\u2374a)\u00f7\u2368+\/2*\u2368a-(\u2374a)\u00f7\u2368+\/a}\r\n<\/code><\/pre>\n<p>I believe this formulation comes naturally because <code class=\"language-apl\">\u2368<\/code> can be used to write functions in the order that they are applied. Another way to put it is that <code class=\"language-apl\">\u2368<\/code> reduces the need for long-scope parentheses. For example:<\/p>\n<pre><code class=\"language-apl\">   (2\u00d7a) \u00f7\u2368 (-b) (+,-) 0.5 *\u2368 (b*2)-4\u00d7a\u00d7c\r\n   ((-b) (+,-) ((b*2)-4\u00d7a\u00d7c)*0.5) \u00f7 2\u00d7a\r\n<\/code><\/pre>\n<p>That <code class=\"language-apl\">\u2368<\/code> is easy to implement, <code class=\"language-apl\">{\u237a\u2190\u2375 \u22c4 \u2375 \u237a\u237a \u237a}<\/code>, is neither here nor there; its value as a tool of thought is easily demonstrated.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The monadic operator \u2368 is defined and modeled as follows: f\u2368 \u2375 \u2190\u2192 \u2375 f \u2375 \u237a f\u2368 \u2375 \u2190\u2192 \u2375 f \u237a {\u237a\u2190\u2375 \u22c4 \u2375 \u237a\u237a \u237a} Reflex Some common well-known functions can be written as f\u2368 where f &hellip; <a href=\"https:\/\/www.dyalog.com\/blog\/2015\/10\/the-reflexcommute-operator\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-3321","post","type-post","status-publish","format-standard","hentry","category-apl-language"],"_links":{"self":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/3321","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\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/comments?post=3321"}],"version-history":[{"count":9,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/3321\/revisions"}],"predecessor-version":[{"id":3378,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/3321\/revisions\/3378"}],"wp:attachment":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/media?parent=3321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/categories?post=3321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/tags?post=3321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}