Created
March 17, 2012 03:57
-
-
Save hgarcia/2054805 to your computer and use it in GitHub Desktop.
Learning Erlang
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> lists:append([[2,3,4],[5,6],[2,5,6]]). | |
[2,3,4,5,6,2,5,6] | |
2> lists:append([2,3,4],[4,5,6]). | |
[2,3,4,4,5,6] | |
3> lists:concat([an, atomic, bomb, is, big, trouble]). | |
"anatomicbombisbigtrouble" | |
4> lists:concat(["/", users, "/" , "find", "." ,"html"]). | |
"/users/find.html" |
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> A = [1,2,3,4]. | |
[1,2,3,4] | |
2> B = [5,6|A]. | |
[5,6,1,2,3,4] | |
3> C = [1,2,3|[]]. | |
[1,2,3] |
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> A = [1,2,3,{name, last}]. | |
2> A. | |
[1,2,3,{name,last}] | |
3> T = {name, last, age, {dog, charlie}}. | |
4> T. | |
{name,last,age,{dog,charlie}} |
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> lists:sort([a,c,d,g,e,f]). | |
[a,c,d,e,f,g] | |
2> lists:sort([2,4,3,1,5,6,0,10,9]). | |
[0,1,2,3,4,5,6,9,10] | |
3> lists:sort([2,4,3,1,5,6,0,10,9,8,7]). | |
[0,1,2,3,4,5,6,7,8,9,10] | |
4> lists:sort([$g,$d,$a,$b,$u]). | |
"abdgu" | |
5> A = a. | |
6> lists:sort([2,3,a,g,6,$d,A]). | |
[2,3,6,100,a,a,g] |
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> A = [1, 2, 3, 4, hello, world]. | |
[1,2,3,4,hello,world] | |
2> B = A. | |
3> B. | |
[1,2,3,4,hello,world] | |
4> [C] = A. | |
** exception error: no match of right hand side value [1,2,3,4,hello,world] | |
5> [C|_] = A. | |
6> C. | |
1 | |
7> _. | |
* 1: variable '_' is unbound | |
8> [H|Tail] = A. | |
9> H. | |
1 | |
10> Tail. | |
[2,3,4,hello,world] | |
11> [D,E|T] = [1,2,45,67,[a]]. | |
12> D. | |
1 | |
13> E. | |
2 | |
14> T. | |
[45,67,[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
6> lists:merge([[1,2,3],[4,3,5],[6,2,7]]). | |
[1,2,3,4,3,5,6,2,7] | |
7> lists:merge([[1,2,3],[3,4,5],[2,6,7]]). | |
[1,2,2,3,3,4,5,6,7] | |
8> lists:merge([2,3,4,5],[3,6,7,2,8]). | |
[2,3,3,4,5,6,7,2,8] | |
9> lists:umerge([2,3,4,5],[3,6,7,2,8]). | |
[2,3,4,5,6,7,2,8] | |
10> lists:umerge([2,3,4,5],[2,3,6,7,8]). | |
[2,3,4,5,6,7,8] |
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> lists:reverse([4,5,6,atomic,7,bomb]). | |
[bomb,7,atomic,6,5,4] |
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> [68,121,110,97,109,105,99]. | |
"Dynamic" | |
2> Dynamic = [68,121,110,97,109,105,99]. | |
3> Dynamic. | |
"Dynamic" | |
4> C = "Another string". | |
5> C. | |
"Another string" | |
6> [H|T] = C. | |
7> H. | |
65 | |
8> T. | |
"nother string" | |
9> H = "A". | |
** exception error: no match of right hand side value "A" | |
10> H = 65. | |
65 | |
11> D = "A". | |
12> D. | |
"A" | |
13> D = [65]. | |
"A" | |
14> [$H,$e,$r,$n,$a,$n]. | |
"Hernan" |
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> A = [1,2|3]. | |
[1,2|3] | |
2> [H|T] = A. | |
3> T. | |
[2|3] | |
4> [H2|T2] = T. | |
5> T2. | |
3 | |
6> [H3|T3] = T2. | |
** exception error: no match of right hand side value 3 | |
1> A= [1,2|[3]]. | |
[1,2,3] | |
2> [H|T] = A. | |
3> T. | |
[2,3] | |
4> [H2|T2] = T. | |
5> T2. | |
3 | |
6> [H3|T3] = T2. | |
[3] | |
7> T3. | |
[] | |
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> A. | |
* 1: variable 'A' is unbound %% Calling an unbound variable | |
2> A = 1. %% Bounding A to 1 | |
3> A. | |
1 | |
4> B = 'a name'. %% Bounding B to the 'a name' Atom | |
5> B. | |
'a name' | |
6> A = B. %% A and B don't match | |
** exception error: no match of right hand side value 'a name' | |
7> C = 'a name'. %% Bounding C to the 'a name' Atom | |
8> B = C. %% B and C do match | |
'a name' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment