Function matching w/ "abc" ++ Rest
Fri Dec 9 10:44:07 CET 2005
Peter-Henry Mander <erlang@REDACTED> writes:
> Assuming tha code was supposed to read:
> f1("abc" ++ Rest) ->
> f1("def" ++ Rest) ->
> You would be better off writing:
> f1([$a,$b,$c|_Rest]) -> abc;
> f1([$d,$e,$f|_Rest]) -> def.
The compiler generates exactly the same code for the two
ways of writing the function.
Björn Gustavsson, Erlang/OTP, Ericsson AB
More information about the erlang-questions