Meaning of [a]++b

Matthias Lang matthias@REDACTED
Thu Jan 16 20:03:36 CET 2003


Eric Newhuis writes:
 > Can someone provide or point me in the direction of an explanation of
 > what this means?
 > 
 > > [a] ++ b
 > [a|b]
 > 
 > Is this a quirk that has a useful side-effect that is a feature?  Or was
 > this an intentional feature from the beginning?  It reminds me of
 > something I saw in Lisp, the dot operator or something.  My memory fails
 > me.

Since you appear to be familiar with Lisp, take a look at

   http://cs.gmu.edu/~sean/cs480/cons/

[a|b] is Erlang notation for a cons cell. You can implement many data
structures using a cons cell, including linked lists. The ++ operator
is intended for concatenating lists, but it happens to work for some
other arguments too. Try writing an 'append' function by hand and
you'll see why. I'd call it a quirk, though a well-defined one.

Matthias



More information about the erlang-questions mailing list