[erlang-questions] lists:concat with non-string sublists

Ladislav Lenart lenartlad@REDACTED
Wed May 23 10:37:26 CEST 2012


On 22.5.2012 20:46, James Aimonetti wrote:
>>> [snip]
>>> So, according to the docs, I would expect:
>>>> lists:concat([[{foo, 123}], [{bar, 234}]]).
>>> to fail. It doesn't, and returns [{foo, 123}, {bar,234}]. Reading
>>> the implementation of concat/1 its easy to see why this works.
>> [snip]
>> Typical example of this is something like lists:append/2:
>> -spec append(list(), list()) -> list(). % or something more
>> involved
>> but the implementation may allow for calls of the form:
>> Eshell V5.9.2  (abort with ^G) 1> lists:append([], 3.14). 3.14
>> but you probably would not want to change its spec to allow term()
>> for its second argument and return, would you?
> Indeed not, wrt to the lists:append/2 example. I guess the safer
> course of action, in my case, is to implement my own concat/1 for my
> list of lists of tuples, to ensure that lists:concat/1 doesn't change
> down the road to enforce the spec more strictly?

What about lists:append/1? That should be suitable for your use case, or am I
missing something?

Ladislav Lenart

More information about the erlang-questions mailing list