<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="204168" data-post-id="204168">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Matsa59" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Matsa59/120/20270_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Matsa59
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>With time you’ll start thinking different (some one already say that <img src="https://forum.elixirforum.com/images/emoji/apple/thinking.png?v=15" title=":thinking:" class="emoji" alt=":thinking:" loading="lazy" width="20" height="20"> )</p>
<p>In general term, you use tuple for a structured data that you know the size in compile time. In your case we can’t.</p>
<p>But why knowing the size is so important? It allows you to play easily with the data.</p>
<p>For example pattern matching become an elegant way to accomplish things. With list, you can use [tail | head] for matching data.</p>
<p>E.g:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">[h|t] = [1,2,3]
# h -&gt; 1
# y -&gt; [2,3]
</code></pre>
<p>Doing this with tuple is little bit harder. The first way is : you now the size you can match data so you can do something like the code bellow</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">{a,b,c} = {1,2,3}
</code></pre>
<p>However, imagine you put 50 elements in the tuple and it become a nightmare.</p>
<p>Or you can use <code>elem/2</code> But it’s not a pattern matching and it will not be useful in our case.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">elem({1,2,3}, 1) 
2
</code></pre>
<p>I explain you that because the main thing about functional programming is thinking of the future. When you write a function your main goal is to provide a piece of code that could be use again and again without any modification. That’s why I had 3 little functions instead of one bigger. Each one does exactly one thing.</p>
<p>So here, I use a list because needs could evolve to : if there is rights numbers but in different order print « you were close » in the console. Doing this with list a pretty easy and the code will be elegant (It could be an great exercice btw).</p>
<p>And for charlists, you can take a look at <a href="https://stackoverflow.com/questions/30037914/elixir-lists-interpreted-as-char-lists" rel="noopener nofollow ugc">https://stackoverflow.com/questions/30037914/elixir-lists-interpreted-as-char-lists</a></p>
<aside class="quote no-group quote-modified" data-username="tommy" data-post="10" data-topic="37664">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/t/b5a626/48.png" class="avatar"> tommy:</div>
<blockquote>
<p>With my dyslexia…</p>
</blockquote>
</aside>
<p>When I was young I was diagnosed with dyslexia. With time, code help me a lot. Keep in mind dyslexia is an advantage. Your brain work differently and it will give you the opportunity to think how to accomplish things differently.</p>
<p>Have a great day <img src="https://forum.elixirforum.com/images/emoji/apple/wink.png?v=15" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="204168" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/if-expression-in-a-cond-syntaxerror-unexpected-token-the-do-at-line-77-is-missing-terminator-end/37664/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-204168" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="204168"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>