Jump to content

Erlang Programming/Variables

From Wikibooks, open books for an open world

Variables in Erlang

Technically there are no variables in Erlang in the sense of multiple assignment. There are Dummy Variables which can take matching values in functions. Once matched their values do not change. Variables in erlang must start with a Capital letter from the Latin 1 character set.

Latin-1 have the following classifications in Erlang:

Decimal       Example  Type of character
--------------------------------------------------
0  - 31                Control character
32                     Space
33 - 47                Punctuation
48 - 57        0-9     Digit
58 - 64                Punctuation
65 - 90        A-Z     Uppercase
91 - 96                Punctuation
97 - 122       a-z     Lowercase
123 - 127              Punctuation
Decimal       Example  Type of character
--------------------------------------------------
128 - 159              Control characters
160 - 191        - ¿   Punctuation 
192 - 214      À - Ö   Uppercase
               ×       Punctuation 
216 - 222      Ø - Þ   Uppercase 
223 - 246      ß - ö   Lowercase 	        
247            ÷       Punctuation 
248 - 255      ø - ÿ   Lowercase

Examples of variables

19> ß = 1.
** exception error: no match of right hand side value 1
20> Þ = a.
a
21> A = ß.
ß

Explanation

Þ is a capital letter so it can be a variable.
ß is not a capital letter so it can not be a variable, but it can be a symbol value.