{"id":1437,"date":"2014-10-16T13:44:41","date_gmt":"2014-10-16T13:44:41","guid":{"rendered":"http:\/\/www.dyalog.com\/blog\/?p=1437"},"modified":"2014-10-16T13:48:43","modified_gmt":"2014-10-16T13:48:43","slug":"selective-expression-tracing","status":"publish","type":"post","link":"https:\/\/www.dyalog.com\/blog\/2014\/10\/selective-expression-tracing\/","title":{"rendered":"Selective Expression Tracing"},"content":{"rendered":"<p>Operator\u00a0<a href=\"http:\/\/dfns.dyalog.com\/n_trace.htm\" target=\"_blank\">trace<\/a>\u00a0from <a href=\"http:\/\/dfns.dyalog.com\/n_contents.htm\" target=\"_blank\">dfns.dws<\/a> is a simple and low-tech tool for displaying intermediate results of functions, during the evaluation of an expression. For example, what&#8217;s going on here?<\/p>\n<pre><code class=\"language-apl\">      (+\u233f \u00f7 \u2262) 1 2 3 4\r\n2.5<\/code><\/pre>\n<p>We can guess that the above fork is computing the average of the right argument.\u00a0To see how this works:<\/p>\n<pre><code class=\"language-apl\">      )copy dfns trace\r\n...\r\n\r\n\u235d Rename to reduce clutter\r\n\r\n      t \u2190 trace\r\n\r\n\u235d Bind each \"tine\" of the fork with t to see what's happening\r\n\r\n      (+\u233ft \u00f7t \u2262t) 1 2 3 4\r\n\u2262 \u00a01 2 3 4 \u00a0=&gt; \u00a04\r\n+\u233f \u00a01 2 3 4 \u00a0=&gt; \u00a010\r\n10 \u00a0\u00f7 \u00a04 \u00a0=&gt; \u00a02.5\r\n2.5\r\n\r\n\u235d But how is that +\u233f reduction evaluated?\r\n\r\n      (+t\u233f \u00f7 \u2262) 1 2 3 4\r\n3 \u00a0+ \u00a04 \u00a0=&gt; \u00a07\r\n2 \u00a0+ \u00a07 \u00a0=&gt; \u00a09\r\n1 \u00a0+ \u00a09 \u00a0=&gt; \u00a010\r\n2.5<\/code><\/pre>\n<p>As a second example, what does the atop <code class=\"language-apl\">(~\u2377)<\/code> do in the following function to remove superfluous <code class=\"language-apl\">'.'<\/code> characters from its argument?<\/p>\n<pre><code class=\"language-apl\">      {('\u00b7\u00b7'(~\u2377)\u2375)\/\u2375} 'squeeze\u00b7\u00b7\u00b7\u00b7\u00b7me'\r\nsqueeze\u00b7me\r\n\r\n      {('\u00b7\u00b7'(~\u2377)t\u2375)\/\u2375} 'squeeze\u00b7\u00b7\u00b7\u00b7\u00b7me'\r\n\u00b7\u00b7 \u00a0~\u2377 \u00a0squeeze\u00b7\u00b7\u00b7\u00b7\u00b7me \u00a0=&gt; \u00a01 1 1 1 1 1 1 0 0 0 0 1 1 1\r\nsqueeze\u00b7me<\/code><\/pre>\n<p>&#8230;and so forth. Notice how <code class=\"language-apl\">t<\/code> can be injected to the right of any of the functions in an expression.<\/p>\n<p>For more examples, see the notes for\u00a0<a href=\"http:\/\/dfns.dyalog.com\/n_trace.htm\" target=\"_blank\">trace<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Operator\u00a0trace\u00a0from dfns.dws is a simple and low-tech tool for displaying intermediate results of functions, during the evaluation of an expression. For example, what&#8217;s going on here? (+\u233f \u00f7 \u2262) 1 2 3 4 2.5 We can guess that the above &hellip; <a href=\"https:\/\/www.dyalog.com\/blog\/2014\/10\/selective-expression-tracing\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1437","post","type-post","status-publish","format-standard","hentry","category-apl-language"],"_links":{"self":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/1437","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\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/comments?post=1437"}],"version-history":[{"count":12,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/1437\/revisions"}],"predecessor-version":[{"id":1449,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/1437\/revisions\/1449"}],"wp:attachment":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/media?parent=1437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/categories?post=1437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/tags?post=1437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}