[erlang-questions] List matching, help me make this look better

Gleb Peregud gleber.p@REDACTED
Sat Apr 25 23:10:36 CEST 2009


On Sat, Apr 25, 2009 at 22:05, Jarrod Roberson <jarrod@REDACTED> wrote:
>>   myfunc("aaaa " ++ R) ->
>>       io:format("matthed aaaa~n"),
>>       io:format("R matches 123 in your example file");
>
> can somebody explain what the ++ operator is called and is doing there?

AFAIK code

myfunc("abc" ++ R) ->
   ok.

is just a syntactic sugar for the code:

myfunc([$a, $b, $c | R]) ->
   ok.

So operator ++ is just compiled into the appropriate matching code. It
works everywhere where pattern matching is performed.



More information about the erlang-questions mailing list