Reputation: 578
We can make a nested list in erlang by writing something like this:
NL = [[2,3], [1]].
[[2,3],[1]]
But assume we wrote it like this instead:
OL = [[2,3]|1].
[[2,3]|1]
Is OL still a list? Can someone please elaborate more what OL is?
Upvotes: 4
Views: 162
Reputation: 20916
More information about |
and building list is given in Functional Programming: what is an "improper list"? .
Upvotes: 3
Reputation: 5500
This is called an improper list and should typically not be used. I think most library functions expects proper lists (e.g. length([1|2]) throws bad argument exception). Pattern matching with improper lists works though.
For some use cases, see Practical use of improper lists in Erlang (perhaps all functional languages)
Upvotes: 5