<div dir="ltr">Thanks to another comment, I see this is "cons" at work making lists where the last element is not a list, as Dmytro said. I got it now.<div><br></div><div>
<p class=""><font face="courier new, monospace">130> [[hello] | hello].</font></p>
<p class=""><font face="courier new, monospace">[[hello]|hello]</font></p>
<p class=""><font face="courier new, monospace">131> [world,[hello] | hello].</font></p>
<p class=""><font face="courier new, monospace">[world,[hello]|hello]</font></p>
<p class=""><font face="courier new, monospace">132> List5 = [world,[hello] | hello].</font></p>
<p class=""><font face="courier new, monospace">[world,[hello]|hello]</font></p>
<p class=""><font face="courier new, monospace">133> lists:reverse(List5). </font></p>
<p class=""><font face="courier new, monospace">** exception error: bad argument</font></p>
<p class=""><font face="courier new, monospace"> in function lists:reverse/2</font></p>
<p class=""><font face="courier new, monospace"> called as lists:reverse(hello,[[hello],world])</font></p>
<p class=""><font face="courier new, monospace"> in call from lists:reverse/1 (lists.erl, line 152)</font></p>
<p class=""><font face="courier new, monospace">134> List5.</font></p>
<p class=""><font face="courier new, monospace">[world,[hello]|hello]</font></p>
<p class=""><font face="courier new, monospace">135> is_list(List5).</font></p>
<p class=""><font face="courier new, monospace">true</font></p>
<p class=""><font face="courier new, monospace">136> </font></p></div><div><div><br></div><div>That is a bit quirky, but hey it's Erlang! The quick hack for my code was to replace "lists:reverse(L4)" with my little strip_lists_rev(L4).<div><br></div><div><font face="courier new, monospace"><br>strip_lists_rev(0,Acc)-><br> Acc;<br>strip_lists_rev([H|Rest],Acc)-><br> strip_lists_rev(Rest,[H|Acc]).</font></div><div><font face="courier new, monospace"><br></font></div><div><div class="gmail_extra"><br></div><div class="gmail_extra">Hopefully, this won't impact performance and reliability too much. </div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks again.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Sep 21, 2014 at 8:07 AM, Stu Bailey <span dir="ltr"><<a href="mailto:stu.bailey@gmail.com" target="_blank">stu.bailey@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Thanks. I actually wanted to reverse the list of lists lists:reverse(L4). I did not know about "irregular lists". Now I do. <div><br></div><div>Thanks again!<div><div class="h5"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Sep 21, 2014 at 8:00 AM, Dmytro Lytovchenko <span dir="ltr"><<a href="mailto:dmytro.lytovchenko@gmail.com" target="_blank">dmytro.lytovchenko@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Oh and also its list of another list and 0 as tail element. You probably want to reverse first element of L4, like lists:reverse(hd(L4)).<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Sep 21, 2014 at 4:51 PM, Dmytro Lytovchenko <span dir="ltr"><<a href="mailto:dmytro.lytovchenko@gmail.com" target="_blank">dmytro.lytovchenko@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>It is irregular list, that is list which doesn't have [] as tail element, and has 0 there instead. While its legal to have such a value, some list handling functions will be waiting for [] as tail element thus they will be confused.<br></div>Solution: don't have 0 there, or cut it away temporarily and append later as X = [CutList | 0].<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Sun, Sep 21, 2014 at 4:46 PM, Stu Bailey <span dir="ltr"><<a href="mailto:stu.bailey@gmail.com" target="_blank">stu.bailey@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div dir="ltr">I'm sure I'm missing something obvious, but here goes:<div><br></div><div>What is going on here? Is L4 a list? If so, why can't I reverse it?</div><div><br></div><div>
<p><font face="courier new, monospace">70> L4. </font></p>
<p><font face="courier new, monospace">[[<<"8">>,<<"7">>,<<"6">>,<<"5">>],</font></p>
<p><font face="courier new, monospace"> [<<"4">>,<<"3">>,<<"2">>,<<"1">>]|</font></p>
<p><font face="courier new, monospace"> 0]</font></p>
<p><font face="courier new, monospace">71> lists:reverse(L4).</font></p>
<p><font face="courier new, monospace">** exception error: bad argument</font></p>
<p><font face="courier new, monospace"> in function lists:reverse/2</font></p>
<p><font face="courier new, monospace"> called as lists:reverse(0,</font></p>
<p><font face="courier new, monospace"> [[<<"4">>,<<"3">>,<<"2">>,<<"1">>],</font></p>
<p><font face="courier new, monospace"> [<<"8">>,<<"7">>,<<"6">>,<<"5">>]])</font></p>
<p><font face="courier new, monospace"> in call from lists:reverse/1 (lists.erl, line 152)</font></p>
<p><font face="courier new, monospace">72> [Head1|Rest1] = L4.</font></p>
<p><font face="courier new, monospace">[[<<"8">>,<<"7">>,<<"6">>,<<"5">>],</font></p>
<p><font face="courier new, monospace"> [<<"4">>,<<"3">>,<<"2">>,<<"1">>]|</font></p>
<p><font face="courier new, monospace"> 0]</font></p>
<p><font face="courier new, monospace">73> Rest1.</font></p>
<p><font face="courier new, monospace">[[<<"4">>,<<"3">>,<<"2">>,<<"1">>]|0]</font></p>
<p><font face="courier new, monospace">74> lists:reverse(Rest1).</font></p>
<p><font face="courier new, monospace">** exception error: no function clause matching lists:reverse([[<<"4">>,<<"3">>,<<"2">>,<<"1">>]|0]) (lists.erl, line 145)</font></p>
<p><font face="courier new, monospace">75> [Head2|Rest2] = Rest1.</font></p>
<p><font face="courier new, monospace">[[<<"4">>,<<"3">>,<<"2">>,<<"1">>]|0]</font></p>
<p><font face="courier new, monospace">76> Head2.</font></p>
<p><font face="courier new, monospace">[<<"4">>,<<"3">>,<<"2">>,<<"1">>]</font></p>
<p><font face="courier new, monospace">77> Rest2. </font></p>
<p><font face="courier new, monospace">0</font></p>
<p><font face="courier new, monospace">78></font></p><p><br></p><p>In practice, the kind of structure demonstrated in L4 is being returned by a function from another library I'm trying to use, but I'm trying to understand what's going on in general.</p></div></div>
<br></div></div>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div></div></div>
</blockquote></div><br></div></div></div></div></div>