Need Erlang help for novice.

Raimo Niskanen <>
Mon Oct 9 14:34:44 CEST 2000


Now, this was a real novice question, and here is the answer.

The '=' operator in Erlang is not an assignment operator, but a pattern
match operator. You tried to match the atom 'a' with the integer '2',
which failed, and then the atom 'a' with the list of characters
"testing", which also failed. 

Variables in Erlang all start with an uppercase letter, so if You try:
1> A = 2.
it will succeed, but then
2> A = "testing".
will fail because A is already bound to 2, and a variable can only be
bound once. Variables are often bound as function arguments, which is
useful, since the only way to "change" a variable is to calculate a new
value and use it when calling some function. This is the essense of
functional languages. 

For an introduction read the first chapter of the book "Concurrent
Programming in Erlang" from the URL
http://erlang.ericsson.se/doc/index.shtml.

/ Raimo Niskanen, Erlang/OTP



akhilesh maewal wrote:
> 
> I have downloaded the latest version of Erlang. When I
> start the shell and give some commands, the following
> lines describe what I get.
> -------------------------------------------------------
> Erlang (BEAM) emulator version 5.0.1 [threads]
> 
> Eshell V5.0.1  (abort with ^G)
> 1> a=2.
> ** exited: {{badmatch,2},[{erl_eval,expr,3}]} **
> 2> a="testing".
> ** exited: {{badmatch,"testing"},[{erl_eval,expr,3}]}
> **
> 3>
> --------------------------------------------------
> 
> Could any one help me understand why I am getting
> these errors?
> 
> Thank you very much.
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!
> http://photos.yahoo.com/



More information about the erlang-questions mailing list