<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Some numbers <br>
    </p>
    <p>1> erts_debug:flat_size([a,b]).<br>
      4<br>
      2> erts_debug:flat_size({a,b}).<br>
      3<br>
      3> erts_debug:flat_size([a|b]).<br>
      2<br>
      <br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 06/29/2018 03:35 AM, Dmytro
      Lytovchenko wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAOUb9CEMVFZRyMtnbaZ7Vp3p0hnT7W8Pa1PTvEudEqk=XV=aKg@mail.gmail.com">
      <div dir="ltr">
        <div>A tuple of 2 elements will take 3 words of memory minimum</div>
        <div><a
href="http://beam-wisdoms.clau.se/en/latest/indepth-memory-layout.html#tuple-arityval-0"
            moz-do-not-send="true">http://beam-wisdoms.clau.se/en/latest/indepth-memory-layout.html#tuple-arityval-0</a></div>
        <div>tuple1 = [ headerWord, element1, element2 ]<br>
        </div>
        <div><br>
        </div>
        <div>A cons cell has no header word, so an improper list of 1
          element and 2nd element as a tail, just 2 values stored side
          to side<br>
        </div>
        <div>(same as normal list below except that only 1 cons cell is
          used, 2 words)</div>
        <div>cons1 = [ element1, element2 ]<br>
        </div>
        <div><br>
        </div>
        <div>
          <div>A proper list of 2 elements will take 2 cons cells, i.e.
            4 words of memory minimum</div>
          <div>cons2 = [ element2, [] ]<br>
          </div>
          <div>cons1 = [ element1, cons2 ]<br>
          </div>
          <div><a
href="http://beam-wisdoms.clau.se/en/latest/indepth-memory-layout.html#lists-cons"
              moz-do-not-send="true">http://beam-wisdoms.clau.se/en/latest/indepth-memory-layout.html#lists-cons</a><br>
          </div>
          <div><br>
          </div>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">2018-06-29 2:23 GMT+02:00 Dmitry
          Belyaev <span dir="ltr"><<a
              href="mailto:be.dmitry@gmail.com" target="_blank"
              moz-do-not-send="true">be.dmitry@gmail.com</a>></span>:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">
              <div>It's a way to reduce memory footprint.</div>
              <div><br>
              </div>
              <div>Tuple of size N is roughly represented in memory as
                an array [TupleTag, N, TupleElement1, TupleElement2,
                ..., TupleElementN].</div>
              <div>Compare it to Cons cell representation: [ConsTag,
                HeadElement, TailElement] - it saves 1 word per
                structure.<br>
              </div>
              <div class="gmail_extra"><br clear="all">
                <div>
                  <div
                    class="m_7606740003781037632m_2917007213273080743gmail_signature"
                    data-smartmail="gmail_signature">
                    <div dir="ltr">Kind regards,
                      <div>Dmitry Belyaev</div>
                    </div>
                  </div>
                </div>
                <br>
                <div class="gmail_quote">On Fri, Jun 29, 2018 at 9:50
                  AM, Karlo Kuna <span dir="ltr"><<a
                      href="mailto:kuna.prime@gmail.com" target="_blank"
                      moz-do-not-send="true">kuna.prime@gmail.com</a>></span>
                  wrote:<br>
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    <div dir="ltr">dealing with digraph module i have
                      noticed use of improper lists as representations
                      of edges: <br>
                      ['$e' | 123]
                      <div><br>
                      </div>
                      <div>is there a good reason to use improper lists
                        instead of tuple for this and in general </div>
                      <div>when is a good idea to use improper lists??
                        (i can't think of example for justified use)</div>
                    </div>
                    <br>
                    ______________________________<wbr>_________________<br>
                    erlang-questions mailing list<br>
                    <a href="mailto:erlang-questions@erlang.org"
                      target="_blank" moz-do-not-send="true">erlang-questions@erlang.org</a><br>
                    <a
                      href="http://erlang.org/mailman/listinfo/erlang-questions"
                      rel="noreferrer" target="_blank"
                      moz-do-not-send="true">http://erlang.org/mailman/list<wbr>info/erlang-questions</a><br>
                    <br>
                  </blockquote>
                </div>
                <br>
              </div>
            </div>
            <br>
            ______________________________<wbr>_________________<br>
            erlang-questions mailing list<br>
            <a href="mailto:erlang-questions@erlang.org"
              moz-do-not-send="true">erlang-questions@erlang.org</a><br>
            <a
              href="http://erlang.org/mailman/listinfo/erlang-questions"
              rel="noreferrer" target="_blank" moz-do-not-send="true">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
BR,
Dmitry
</pre>
  </body>
</html>