Created
March 19, 2012 03:38
-
-
Save hgarcia/2093388 to your computer and use it in GitHub Desktop.
Learning Erlang 3 Variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1> 1 + 1.0. | |
2.0 | |
2> 2.0 + 1. | |
3.0 | |
3> 4 + 45. | |
49 | |
4> 45 /0.5. | |
90.0 | |
5> 2.0 + a. | |
** exception error: bad argument in an arithmetic expression | |
in operator +/2 | |
called as 2.0 + a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7> [A,B,C] = ["Keep", "it", "simple"]. | |
["Keep", "it", "simple] | |
8> A. | |
"Keep" | |
9> B. | |
"it" | |
10> C. | |
"simple" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Declaration is not needed. | |
1> Variable. | |
* 1: variable 'Variable' is unbound | |
%% Declare an assign at the same time | |
2> Variable = 'an atom'. | |
'an atom' | |
%% Valid variable names | |
3> Long_variable_name_In_here = 1. | |
1 | |
4> AlphaNum3r1c = "a1". | |
"a1" | |
%% Non valid names | |
5> Non-Valid? = ups. | |
* 1: syntax error before: '?' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1> Count = 1. | |
1 | |
2> Count = Count + 1. | |
** exception error: no match of right hand side value 2 | |
3> NewCount = Count + 1. | |
2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment