[erlang-questions] wierd list comprehension outcomes

Bob Ippolito bob@REDACTED
Sun Jan 25 18:24:09 CET 2015


[X|1] is bad because 1 is not a list. Any X would be valid if the tail
was a list.

On Sunday, January 25, 2015, Roelof Wobben <r.wobben@REDACTED> wrote:

> oke,
>
> So [[3,2]|1] is bad because there is more then 1 item.
> If I do [1 | [ 2,3] ] It would be right.
>
> Roelof
>
>
> Imants Cekusins schreef op 25-1-2015 om 14:47:
>
>> For adding items to lists:
>>
>> this is bad:
>> [ any() | Not_a_list ]
>>
>> ok:
>> [ One_item | T_List ]
>>
>> The "T_List" must be a list - even if an empty one: [ ].
>> One_item ideally is not a list: atom, number, tuple, etc
>>
>> for "glueing" lists together, use
>> lists:append/1,2
>>
>>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150125/0b59e3e0/attachment.htm>


More information about the erlang-questions mailing list