<div dir="ltr"><div>A list of 2 elements will consume:</div><div>1 list cell (2 words of memory) to store $n and pointer to second cell</div><div>1 list cell (2 more words) to store N and [] (that's nil, end of proper list)</div><div>total: 4 words of memory, on a 64 bit machine that's 32 bytes</div><div><br></div><div>An improper list of 2 elements will consume:</div><div>1 list cell (2 words of memory) to store $n and tail is stored as N</div><div>total 16 bytes of memory on 64 bit machine</div><div><br></div><div><a href="http://beam-wisdoms.clau.se/en/latest/indepth-memory-layout.html#lists-cons">http://beam-wisdoms.clau.se/en/latest/indepth-memory-layout.html#lists-cons</a></div><div><a href="http://beam-wisdoms.clau.se/en/latest/indepth-data-sizes.html#list">http://beam-wisdoms.clau.se/en/latest/indepth-data-sizes.html#list</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 20 Dec 2021 at 17:23, Fred Youhanaie <<a href="mailto:fly@anydata.co.uk">fly@anydata.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi<br>
<br>
The digraph module uses the term ['$e'|N] to represent an edge.<br>
<br>
Is there an advantage in using an improper list, as opposed to the more intuitive tuple format {'$e', N}?<br>
<br>
I recently came across a situation where the following crashed because logger tried to flatten the list of improper lists!<br>
<br>
logger:notice(#{ edges => digraph:edges(G) }).<br>
<br>
However, these two were OK:<br>
<br>
logger:notice(#{ edges => { digraph:edges(G) } }). %% Note the extra braces<br>
logger:notice("edges = ~w", [digraph:edges(G)] ).<br>
<br>
For me this was a temporary annoyance, but I'm just curious about the choice of list structure. Is this explained anywhere, such as docs or a blog?<br>
<br>
Cheers,<br>
Fred<br>
</blockquote></div>