<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by M0n4d on Medium]]></title>
        <description><![CDATA[Stories by M0n4d on Medium]]></description>
        <link>https://medium.com/@m0n4d?source=rss-8b779fd02762------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LTOK_f5rTCOl3HTHIuNvTg.png</url>
            <title>Stories by M0n4d on Medium</title>
            <link>https://medium.com/@m0n4d?source=rss-8b779fd02762------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 18:36:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@m0n4d/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[JavaScript Chained Conditionals]]></title>
            <link>https://medium.com/@m0n4d/javascript-chained-conditionals-96f9a3751527?source=rss-8b779fd02762------2</link>
            <guid isPermaLink="false">https://medium.com/p/96f9a3751527</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[control-structure]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[functional-programming]]></category>
            <dc:creator><![CDATA[M0n4d]]></dc:creator>
            <pubDate>Fri, 17 May 2019 05:47:13 GMT</pubDate>
            <atom:updated>2019-05-17T05:47:13.168Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Om0I1itOfWcJwRbg" /><figcaption>Photo by <a href="https://unsplash.com/@freegraphictoday?utm_source=medium&amp;utm_medium=referral">AbsolutVision</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Chaining conditional operators in javascript provides a way to concisely express control structures. Using this pattern a control structure can be expressed as a single statement instead of multiple statements(if, else if, else). Functions based on predicate values (conditions) can be defined this way.</p><p>This is the general pattern.</p><pre>const f = x =&gt; {<br>  return predicate1  ? expression1<br>       : predicate2  ? expression2<br>       : predicate3 &amp;&amp; expression3<br>}</pre><p>And here is the equivalent using if and else if statements.</p><pre>const f = x =&gt; {<br>  if (predicate1) {<br>    return expression1<br>  } else if (predicate2) {<br>    return expression2<br>  } else if (predicate3) {<br>    return expression3 <br>  }<br>}</pre><p>The chained conditional pattern strongly resembles Haskell guards and behaves the same way.</p><pre>f x<br>  | predicate1 <strong>=</strong> expression1<br>  | predicate2 <strong>=</strong> expression2<br>  | predicate3 <strong>=</strong> expression3</pre><h4>Conciseness and Readability</h4><p>This pattern allows you to plug and play mathematical functions based on predicate values in a near-verbatim format.</p><p>Here an Ackermann function is defined using mathematical notation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*6U4Oom3E2OatnhhIK8Zoqw.png" /><figcaption>The Ackerman Function</figcaption></figure><p>And here it is again defined in javascript using a chained conditional control structure.</p><pre>const ackermann = (m, n) =&gt; {<br>  return m === 0           ? n + 1<br>       : m &gt; 0 &amp;&amp; n === 0  ? ackermann(m - 1, 1)<br>       : m &gt; 0 &amp;&amp; n &gt; 0   &amp;&amp; ackermann(m - 1, ackermann(m, n -1))   <br>}</pre><p>Here a McCarthy 91 function is defined using mathematical notation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*NhT6FcbzvdWYNLUUdo7ZVg.png" /><figcaption>The McCarthy 91 function</figcaption></figure><p>And here it is again defined in javascript using a chained conditional control structure.</p><pre>const M = n =&gt; {<br>   return n &gt; 100   ? n - 10<br>        : n &lt;= 100 &amp;&amp; M(M(n+11))<br> }</pre><h4>Summary</h4><p>With the ability to represent arbitrarily large control structures and transcribe predicate value based functions in a single concise and readable statement, this pattern is a robust tool for any javascript developer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96f9a3751527" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Github Gists]]></title>
            <link>https://medium.com/@m0n4d/github-gists-9323c95b3066?source=rss-8b779fd02762------2</link>
            <guid isPermaLink="false">https://medium.com/p/9323c95b3066</guid>
            <category><![CDATA[gist]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[M0n4d]]></dc:creator>
            <pubDate>Mon, 25 Feb 2019 18:27:33 GMT</pubDate>
            <atom:updated>2019-02-25T18:34:58.982Z</atom:updated>
            <content:encoded><![CDATA[<h4>Getting the gist of it</h4><p>Github Gists is a <a href="https://en.wikipedia.org/wiki/Pastebin">Pastebin</a>-like service tied to your GitHub account. A gist can be used to share individual files, code snippets, or any collection of files not requiring a folder structure.</p><h4>Usefulness</h4><p>Every gist is a Git repository, which means that it can be forked and cloned. Gists can be commented on and starred by GitHub users. Gists are lightweight and easily embedded into web pages(see below). They also support(by default) markdown to HTML conversion.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc6e6553b47c198f95d149497c1a7084/href">https://medium.com/media/bc6e6553b47c198f95d149497c1a7084/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/554b969bbe379a0a0f8f839cbf23f75c/href">https://medium.com/media/554b969bbe379a0a0f8f839cbf23f75c/href</a></iframe><h4>Creating a Gist</h4><p>Once signed into your GitHub account Navigate to your <a href="https://gist.github.com/">gist home page</a>.</p><p>Type an optional description and name for your gist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*3p15FZ892hrtJKfufGbubg.png" /></figure><p>Type the text of your gist into the gist text box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*1rzdFpzhlbvFK5_F0daNxg.png" /></figure><p>Click Create Gist</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*yvwuY33hZ2S2j3256SeoFg.png" /></figure><h4>Summary</h4><p>GitHub Gits is an economical and versatile tool for sharing code. For more information on forking and cloning gists see <a href="https://help.github.com/en/articles/forking-and-cloning-gists">Forking and Cloning Gists</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9323c95b3066" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hello World]]></title>
            <link>https://medium.com/@m0n4d/hello-world-269334150ebd?source=rss-8b779fd02762------2</link>
            <guid isPermaLink="false">https://medium.com/p/269334150ebd</guid>
            <dc:creator><![CDATA[M0n4d]]></dc:creator>
            <pubDate>Tue, 19 Feb 2019 05:29:32 GMT</pubDate>
            <atom:updated>2019-02-19T05:29:32.465Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zWn9gkJMTTBH-UW2te186Q.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=269334150ebd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>