[erlang-questions] Irregular list

Jachym Holecek freza@REDACTED
Thu Feb 12 16:28:01 CET 2009

# Ladvánszky Károly 2009-02-12:
> Just getting acquainted with this wonderful system, I’ve run into the
> following issue:
> The shell seems to accept a structure like this: [a | b].
> is_list([a | b]) returns true but length([a | b]) raises an exception.
> Is it like an “open list” found in some programming languages?

What might be confusing here is that 'is_list()' is actually a slight
misnomer, [_ | _] is really just a pair (aka "cons cell") regardless
of what values are held as head + tail. The length() function expects
a "proper list", which is [] or a pair such that its second component
is a proper list.

I'm not familiar with the term "open list", but hope the above helps.

	-- Jachym

More information about the erlang-questions mailing list