<div dir="ltr">i have solution just as Yau-Hsien suggested but i was wandering is there highly optimized version (bif of nif) of this. <div>sure one can easily do NIF but i think is_improper_list/1 or is_proper_list/1 should be in standard library. </div><div><br></div><div>improper list is pretty clear term in erlang documentation. </div><div><br></div><div>also why i want this: suppose i want type ob object to be list but i also want some sort of additional information for it, </div><div>then syntax [...|some_type_or_property] seems elegant. </div><div>Alternatives are<br><ul><li>{some_type_or_property, List} <br></li><li>parse transformations</li><li>record or map</li></ul><div>however as i need/want this as input to file:consult parse transformations are difficult here and object wrappers as </div></div><div>tuple, map or record are to verbose and noisy </div><div><br></div><div><br></div><div><h3 class="gmail-iw"><br></h3></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 16, 2018 at 4:17 PM 黃耀賢 (Yau-Hsien Huang) <<a href="mailto:g9414002.pccu.edu.tw@gmail.com">g9414002.pccu.edu.tw@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Yes, Richard, I gave the name because of language issue that I made the is_improper_list/1 working but not be aware of its literal meaning, when I reconsidered
Guilherme's code.<br></div><div><br></div><div>The reason to consider a built-in may be that it won't work when applying length/1 to a value [a|b], getting a bad_arg error. And is_list/1 does not determine whether a value is an improper list.<br></div><div><br></div><div>Then there shell be an augmented version of is_list/1, that ...</div><div><br></div><div>is_improper_list([]) -> false;</div><div>is_improper_list([_|Value]) -> is_improper_list(Value);<br></div><div>is_improper_list(_) -> true.</div><div><br></div><div>Though the good use is to avoid writing some code to put any improper list to your system.<br></div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 16, 2018 at 8:51 PM, Richard O'Keefe <span dir="ltr"><<a href="mailto:raoknz@gmail.com" target="_blank">raoknz@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"><div class="gmail_default" style="font-family:monospace,monospace">It is not entirely clear what you mean by</div><div class="gmail_default" style="font-family:monospace,monospace">an improper list. Presumably [a|b] is an</div><div class="gmail_default" style="font-family:monospace,monospace">improper list, but is b all by itself an</div><div class="gmail_default" style="font-family:monospace,monospace">improper list, or what?</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">I'd be tempted to go with</div><div class="gmail_default" style="font-family:monospace,monospace">is_not_a_proper_list(X) when length(X) >= 0 -> false;</div><div class="gmail_default" style="font-family:monospace,monospace">is_not_a_proper_list(_) -> true.</div><div class="gmail_default" style="font-family:monospace,monospace">but more importantly,</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">- why do you want a built-in (as opposed to a library</div><div class="gmail_default" style="font-family:monospace,monospace"> function)?</div><div class="gmail_default" style="font-family:monospace,monospace">- why do you want this at all?</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div></div><div class="m_-5499768005601503404HOEnZb"><div class="m_-5499768005601503404h5"><div class="gmail_extra"><br><div class="gmail_quote">On 16 July 2018 at 14:37, 黃耀賢 (Yau-Hsien Huang) <span dir="ltr"><<a href="mailto:g9414002.pccu.edu.tw@gmail.com" target="_blank">g9414002.pccu.edu.tw@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"><div>As off topic, the
is_improper_list/1 may be rewritten to ...<br></div><div><br></div><div>is_improper_list([_|Value]) -> is_improper_list(Value);<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-5499768005601503404m_-6288831859988793031h5">On Mon, Jul 16, 2018 at 8:17 AM, Guilherme Andrade <span dir="ltr"><<a href="mailto:g@gandrade.net" target="_blank">g@gandrade.net</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-5499768005601503404m_-6288831859988793031h5"><div dir="ltr">Hello Karlo,<br><div><div class="gmail_extra"><br><div class="gmail_quote"><span>On 16 July 2018 at 01:07, Karlo Kuna <span dir="ltr"><<a href="mailto:kuna.prime@gmail.com" target="_blank">kuna.prime@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="auto"></div><div dir="auto">Is there any built in method of checking if list is improper?</div></div></blockquote><div><br></div></span><div>Something like this should do:<br><br>> is_improper_list(Value) when length(Value) >= 0 -> <br>> false; <br>> is_improper_list(Value) -> <br>> is_list(Value).</div><div><br></div><div>`length/1' will fail upon Value being an improper list.<span class="m_-5499768005601503404m_-6288831859988793031m_-6626343485591287732HOEnZb"><font color="#888888"><br></font></span></div></div><span class="m_-5499768005601503404m_-6288831859988793031m_-6626343485591287732HOEnZb"><font color="#888888"><br>-- <br><div class="m_-5499768005601503404m_-6288831859988793031m_-6626343485591287732m_8064370586653248864gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Guilherme<br></div></div></div></div></div></div>
</font></span></div></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" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><span class="m_-5499768005601503404m_-6288831859988793031HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br><div class="m_-5499768005601503404m_-6288831859988793031m_-6626343485591287732gmail_signature" data-smartmail="gmail_signature"><div><br></div>Best Regards.<div><br></div><div>--- Y-H. H.</div><div><br></div></div>
</font></span></div></div>
<br>_______________________________________________<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" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="m_-5499768005601503404gmail_signature" data-smartmail="gmail_signature"><div><br></div>Best Regards.<div><br></div><div>--- Y-H. H.</div><div><br></div></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" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div>