<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Eric Douglas</title>
    <description>The latest articles on DEV Community by Eric Douglas (@ericdouglas).</description>
    <link>https://dev.to/ericdouglas</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F335343%2F636f17b9-ca83-45ed-8aa6-36caaaf20cd4.jpeg</url>
      <title>DEV Community: Eric Douglas</title>
      <link>https://dev.to/ericdouglas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ericdouglas"/>
    <language>en</language>
    <item>
      <title>Minimalist Roadmap to Becoming a Full-Stack Developer</title>
      <dc:creator>Eric Douglas</dc:creator>
      <pubDate>Tue, 14 Jul 2020 12:31:31 +0000</pubDate>
      <link>https://dev.to/ericdouglas/minimalist-roadmap-to-becoming-a-full-stack-developer-259b</link>
      <guid>https://dev.to/ericdouglas/minimalist-roadmap-to-becoming-a-full-stack-developer-259b</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I fear not someone who has practiced 10,000 kicks once, but I fear someone who has practiced one kick 10,000 times.&lt;/p&gt;

&lt;p&gt;Bruce Lee&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When we are starting to learn about web development, we really struggle to find a clear and feasible path to guide us on this journey.&lt;/p&gt;

&lt;p&gt;Although we have a lot of great schools that certainly will help to conquer this challenge, they might be really expensive.&lt;/p&gt;

&lt;p&gt;We have an awesome alternative to this: Udemy courses! They contain a lot of useful content and are really affordable.&lt;/p&gt;

&lt;p&gt;For me, this is the absolute sweet spot in education: students can access the content paying a small amount, and instructors receive their very deserved reward for investing (a lot of) time preparing the courses. I truly love Udemy courses for this reason ❤.&lt;/p&gt;

&lt;p&gt;But one thing we do not have in Udemy is a roadmap to guide new students about what to study and in which order.&lt;/p&gt;

&lt;p&gt;So with this roadmap below, you can without doubts become a professional developer, and after finish those courses, you will have enough knowledge to decide for your own your next steps 😉&lt;/p&gt;

&lt;p&gt;Good luck on your journey!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;PROTIP&lt;/strong&gt;: invest some time finding/developing your learning methodology.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  HTML &amp;amp; CSS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Udemy: &lt;a href="https://www.udemy.com/course/modern-html-css-from-the-beginning"&gt;Modern HTML &amp;amp; CSS From The Beginning (Including Sass)&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Git
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;FreeCodeCamp: &lt;a href="https://www.youtube.com/watch?v=RGOj5yH7evk"&gt;Git and GitHub for Beginners - Crash Course&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  JAVASCRIPT
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Udemy: &lt;a href="https://www.udemy.com/course/javascript-beginners-complete-tutorial"&gt;The Modern Javascript Bootcamp Course&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  REACT
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Udemy: &lt;a href="https://www.udemy.com/course/complete-react-developer-zero-to-mastery"&gt;Complete React Developer (w/ Redux, Hooks, GraphQL)&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  NODE.JS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Udemy: &lt;a href="https://www.udemy.com/course/nodejs-api-masterclass"&gt;Node.js API Masterclass With Express &amp;amp; MongoDB&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  MONGODB
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Udemy: &lt;a href="https://www.udemy.com/course/mongodb-the-complete-developers-guide"&gt;MongoDB - The Complete Developer's Guide&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>node</category>
      <category>mongodb</category>
    </item>
    <item>
      <title>The beauty of recursion and pattern matching in functional programming languages</title>
      <dc:creator>Eric Douglas</dc:creator>
      <pubDate>Fri, 19 Jun 2020 13:58:02 +0000</pubDate>
      <link>https://dev.to/ericdouglas/the-beauty-of-recursion-and-pattern-matching-in-functional-programming-languages-hmn</link>
      <guid>https://dev.to/ericdouglas/the-beauty-of-recursion-and-pattern-matching-in-functional-programming-languages-hmn</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Llv6AOJ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/lFXKbhd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Llv6AOJ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/lFXKbhd.png" alt="Lookup function to retrieve value from binary tree"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;translations: &lt;a href="https://github.com/ericdouglas/traduz-ai/blob/master/programacao-funcional/beleza-da-programacao-funcional.md"&gt;pt-br&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight erlang"&gt;&lt;code&gt;&lt;span class="c"&gt;%% The lookup function receives a Key and a Node
&lt;/span&gt;&lt;span class="nf"&gt;lookup&lt;/span&gt;&lt;span class="p"&gt;(_,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;'nil'&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class="n"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;lookup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Val&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;_,&lt;/span&gt; &lt;span class="p"&gt;_}})&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Val&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nf"&gt;lookup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;NodeKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;_,&lt;/span&gt; &lt;span class="nv"&gt;Smaller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;_}})&lt;/span&gt; &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="nv"&gt;Key&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nv"&gt;NodeKey&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class="nf"&gt;lookup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Smaller&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;lookup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{_,&lt;/span&gt; &lt;span class="p"&gt;_,&lt;/span&gt; &lt;span class="p"&gt;_,&lt;/span&gt; &lt;span class="nv"&gt;Larger&lt;/span&gt;&lt;span class="p"&gt;}})&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class="nf"&gt;lookup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Larger&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;

&lt;span class="c"&gt;%% Explanation about parameters and data structure
%%
%% Empty node -&amp;gt; {node, 'nil'}
%% Non-empty node -&amp;gt; {node, {Key, Val, Smaller, Larger}}
%% node -&amp;gt; it's just an atom, like a constant
%% Key and Val -&amp;gt; can be of different types
%% Smaller and Larger -&amp;gt; Can be empty or non-empty node structures as well,
%%                       so you can have your binary tree
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I want to invite you to admire the beauty, succinctness and power of the code above [1].&lt;/p&gt;

&lt;p&gt;It is a function to find some value in a binary tree, using &lt;em&gt;recursion&lt;/em&gt; and &lt;em&gt;pattern matching&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;We can see how simple and extremely declarative it is to write a function with these concepts and techniques from functional programming languages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We have absolutely ZERO instructions in order to tell HOW the algorithm should work!&lt;/strong&gt; We just expressed &lt;strong&gt;WHAT&lt;/strong&gt; it will do, not how.&lt;/p&gt;

&lt;p&gt;The code was written in &lt;strong&gt;Erlang&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Detailed explanation
&lt;/h2&gt;

&lt;p&gt;This function will search in a binary tree by the &lt;code&gt;Key&lt;/code&gt; you passed to it and will return a tuple with the &lt;code&gt;Val&lt;/code&gt; (value) associated with the key passed, or &lt;code&gt;undefined&lt;/code&gt; if it was not found.&lt;/p&gt;

&lt;p&gt;A great advantage we have in Erlang and Elixir is the possibility to create more cases for the same function just changing the pattern in its parameters.&lt;/p&gt;

&lt;p&gt;The function has the same name and arity (number of parameters), but since the pattern is different, it is like it was another function.&lt;/p&gt;

&lt;p&gt;The cases will be verified from top to bottom, so we should put more specific cases first, and more general cases in the end. Think about it like a functional way to write &lt;code&gt;switch&lt;/code&gt; or &lt;code&gt;if / else&lt;/code&gt; statements.&lt;/p&gt;

&lt;p&gt;We have 4 possible cases in our &lt;code&gt;lookup/2&lt;/code&gt; function, so let's see what which one does:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;lookup(_, {node, 'nil'})&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The first &lt;code&gt;lookup&lt;/code&gt; will ignore the first value passed to it (&lt;code&gt;_&lt;/code&gt;), and if the second value matches, it will return &lt;code&gt;undefined&lt;/code&gt;. As you can see, the second value is an empty node.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;lookup(Key, {node, {Key, Val, _, _}})&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The second &lt;code&gt;lookup&lt;/code&gt; will see if the &lt;code&gt;Key&lt;/code&gt; we passed is the same &lt;code&gt;Key&lt;/code&gt; in the node passed. If it is, we just found the node that contains the value we want to retrieve.&lt;/p&gt;

&lt;p&gt;In that case, the lookup will return &lt;code&gt;{ok, Val}&lt;/code&gt;, where &lt;code&gt;Val&lt;/code&gt; is the value we are interested in.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;lookup(Key, {node, {NodeKey, _, Smaller, _}}) when Key &amp;lt; NodeKey&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The third &lt;code&gt;lookup&lt;/code&gt; will match the case where the key we passed is different from the key in the node passed.&lt;/p&gt;

&lt;p&gt;We also have a &lt;em&gt;guard clause&lt;/em&gt; in the function signature, to keep it more specific. The guard clause &lt;code&gt;when Key &amp;lt; NodeKey&lt;/code&gt; is important for us to decide in which direction we should go to search the value we expect.&lt;/p&gt;

&lt;p&gt;In that case, we know that if the &lt;code&gt;Key&lt;/code&gt; is smaller than &lt;code&gt;NodeKey&lt;/code&gt;, we need to continue our search in the &lt;code&gt;Smaller&lt;/code&gt; node. So we use a pattern match to extract the &lt;code&gt;Smaller&lt;/code&gt; value and ignore the other data we won't use with &lt;code&gt;_&lt;/code&gt; again.&lt;/p&gt;

&lt;p&gt;To continue our search, when we match the third lookup function, we will call it recursively, now with the following data &lt;code&gt;lookup(Key, Smaller)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This is &lt;strong&gt;recursion&lt;/strong&gt; and &lt;strong&gt;pattern matching&lt;/strong&gt; in action! ❤&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;lookup(Key, {node, {_, _, _, Larger}})&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The last case, and more general one, is when any of the previous &lt;code&gt;lookup&lt;/code&gt; functions were not matched. We know this will only occur when the &lt;code&gt;Key&lt;/code&gt; we passed is different from the &lt;code&gt;Key&lt;/code&gt; in the current node, and the &lt;code&gt;Key&lt;/code&gt; passed is larger than the key in the present node, so we need to continue our search in the &lt;code&gt;Larger&lt;/code&gt; node.&lt;/p&gt;

&lt;p&gt;In that case, we will call &lt;code&gt;lookup&lt;/code&gt; recursively with the following data &lt;code&gt;lookup(Key, Larger)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And that's it!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With ZERO instructions about HOW to do, we have a super simple, declarative, and full-featured function that retrieves a value from a binary tree! This is absolutely amazing and mind-blowing &amp;lt;3.&lt;/p&gt;

&lt;p&gt;I hope you enjoyed it!&lt;/p&gt;

&lt;p&gt;Cheers! :)&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Code excerpt from chapter 7 - Recursion, section "More than lists", from the book Learn You Some Erlang for Great Good. &lt;strong&gt;&lt;a href="https://learnyousomeerlang.com/recursion"&gt;LINK&lt;/a&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>erlang</category>
      <category>functional</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>How to configure Jest on a Next.js project</title>
      <dc:creator>Eric Douglas</dc:creator>
      <pubDate>Wed, 17 Jun 2020 16:05:45 +0000</pubDate>
      <link>https://dev.to/ericdouglas/how-to-configure-jest-on-a-next-js-project-2ic6</link>
      <guid>https://dev.to/ericdouglas/how-to-configure-jest-on-a-next-js-project-2ic6</guid>
      <description>&lt;p&gt;You just need to follow few steps to have Jest enabled in your Next.js application.&lt;/p&gt;

&lt;p&gt;Let's see how to do this!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Install the dependencies
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-D&lt;/span&gt; babel-jest jest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Add the &lt;code&gt;test&lt;/code&gt; script to run yor tests
&lt;/h2&gt;

&lt;p&gt;Inside your &lt;code&gt;package.json&lt;/code&gt; file, add this line in the &lt;code&gt;scripts&lt;/code&gt; section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jest --watch"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, all you need to do is (after we finish the setup), type &lt;code&gt;npm test&lt;/code&gt; on you terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Setup .eslintrc.json
&lt;/h2&gt;

&lt;p&gt;If you are using ESLint, you will need to tell it to stop warning you about Jest functions.&lt;/p&gt;

&lt;p&gt;Create a file called &lt;code&gt;.eslintrc.json&lt;/code&gt; if you don't have one, and add the following code in the &lt;code&gt;env&lt;/code&gt; section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"jest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Final step: .babelrc
&lt;/h2&gt;

&lt;p&gt;Just create a file called &lt;code&gt;.babelrc&lt;/code&gt; and put this inside of it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"presets"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"next/babel"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it! If you need configure some thing particularly related to your project (like ignore certain folder), you can take a look at &lt;a href="https://github.com/vercel/next.js/blob/canary/examples/with-jest/jest.config.js"&gt;this file&lt;/a&gt; and &lt;a href="https://github.com/vercel/next.js/tree/canary/examples/with-jest"&gt;this folder&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Bye! 👋&lt;/p&gt;

</description>
      <category>react</category>
      <category>jest</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Quick Sort implemented in Erlang Analysis</title>
      <dc:creator>Eric Douglas</dc:creator>
      <pubDate>Sat, 13 Jun 2020 17:32:41 +0000</pubDate>
      <link>https://dev.to/ericdouglas/quick-sort-implemented-in-erlang-analysis-1k9h</link>
      <guid>https://dev.to/ericdouglas/quick-sort-implemented-in-erlang-analysis-1k9h</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;When you want to &lt;strong&gt;truly&lt;/strong&gt; understand what you are studying, you &lt;strong&gt;must&lt;/strong&gt; go all the way down in the rabbit hole in order to absorb the content.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is a step by step analysis of what is happening in a quick sort algorithm implemented in the book &lt;em&gt;Learn you Some Erlang for Great Good&lt;/em&gt; [1].&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;recursive.erl&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight erlang"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="ni"&gt;module&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;recursive&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;

&lt;span class="p"&gt;-&lt;/span&gt;&lt;span class="ni"&gt;export&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;partition&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quick_sort&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;

&lt;span class="nf"&gt;quick_sort&lt;/span&gt;&lt;span class="p"&gt;([])&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;span class="nf"&gt;quick_sort&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nv"&gt;Pivot&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nv"&gt;Rest&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;Smaller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Larger&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;partition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Pivot&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Rest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="p"&gt;[]),&lt;/span&gt;
    &lt;span class="nf"&gt;quick_sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Smaller&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;Pivot&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="nf"&gt;quick_sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Larger&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;

&lt;span class="nf"&gt;partition&lt;/span&gt;&lt;span class="p"&gt;(_,&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="nv"&gt;Smaller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Larger&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;Smaller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Larger&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nf"&gt;partition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Pivot&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;H&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nv"&gt;T&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nv"&gt;Smaller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Larger&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;H&lt;/span&gt; &lt;span class="o"&gt;=&amp;lt;&lt;/span&gt; &lt;span class="nv"&gt;Pivot&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;
           &lt;span class="nf"&gt;partition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Pivot&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;H&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nv"&gt;Smaller&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nv"&gt;Larger&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="nv"&gt;H&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;Pivot&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;partition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Pivot&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Smaller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;H&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nv"&gt;Larger&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Analysis&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;quick_sort([5, 2, 2, 7, 6, 3])
  Pivot = 5
  Rest = [2, 2, 7, 6, 3]
  {Smaller, Larger} = ???

  partition(5, [2, 2, 7, 6, 3], [], [])
    Pivot = 5
    H = 2
    T = [2, 7, 6, 3]
    Smaller = []
    Larger = []

    partition(5, [2, 7, 6, 3], [2, []], [])
      Pivot = 5
      H = 2
      T = [7, 6, 3]
      Smaller = [2, []]
      Larger = []

      partition(5, [7, 6, 3], [2, [2, []]], [])
        Pivot = 5
        H = 7
        T = [6, 3]
        Smaller = [2, [2, []]]
        Larger = []

        partition(5, [6, 3], [2, [2, []]], [7, []])
          Pivot = 5
          H = 6
          T = [3]
          Smaller = [2, [2, []]]
          Larger = [7, []]

          partition(5, [3], [2, [2, []]], [6, [7, []]])
            Pivot = 5
            H = 3
            T = []
            Smaller = [2, [2, []]]
            Larger = [6, [7, []]]

            partition(5, [], [3, [2, [2, []]]], [6, [7, []]])
              Smaller = [3, [2, [2, []]]]
              Larger = [6, [7, []]]

  {Smaller, Larger} = {[3, [2, [2, []]]], [6, [7, []]]}

  %% (1) quick_sort([3, [2, [2, []]]] = Smaller) ++ [5 = Pivot] ++ (2) quick_sort([6, [7, []]] = Larger)
  quick_sort([3, 2, 2]) ++ [5] ++ quick_sort([6, 7])

  %% Solving (1) until the end
  quick_sort([3, 2, 2]) = quick_sort([2, 2]) ++ [3] ++ quick_sort([])
    quick_sort([2, 2]) = quick_sort([2]) ++ [2] ++ quick_sort([])
      quick_sort([2]) = quick_sort([]) ++ [2] ++ quick_sort([])

  %% Solving (2) until the end
  quick_sort([6, 7]) = quick_sort([]) ++ [6] ++ quick_sort([7])
    quick_sort([7]) = quick_sort([]) ++ [7] ++ quick_sort([])

  %% Replacing the values from our first quick_sort run
  %% obs 1: quick_sort([]) == []
  %% obs 2: consider that some values are from the left side quick_sort and other from righ side quick_sort

  %% quick_sort([3, 2, 2]) ++ [5] ++ quick_sort([6, 7])
  [2] ++ [2] ++ [3] ++ [5] ++ [6] ++ [7]

  %% Result
  [2, 2, 3, 5, 6, 7]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://learnyousomeerlang.com/recursion"&gt;Book LYSE - chapter: Recursion&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>erlang</category>
      <category>computerscience</category>
    </item>
  </channel>
</rss>
