Erlang基础:
每条语句以一个“.”结束。
%是erlang语言的注释,注释从%开始,一直到行尾。一般情况下,erlang源程序中%%做为注释,我想可能是看起来比较显眼。
1.整形(integers)
1.Erlang中的整形包括全部的数字。
2.Erlang遵守四则表达式的规则,可以计算很大的数字。
2#1010为二进制中的10,-16#EA为十六进制中的-234.所以2#表示二进制。
3.所有的字母都是以ASCII码存储的。
$a为97,$\n为10,$A为65.
2.浮点型(Floats)
Erlang中的浮点数为真实地数字。如17.909 ,1.234E-10表示1.234x10(-10次方)。
数学运算
+ Unary+
- Unary-
* Multiplication
/ Floating-point division
div integer remainder
rem Integer remainder 余数
11 div 5. 为2 11 rem 5 .为1
3. 原子(Atoms)
1.Erlang中atoms用来表示不同的常量。
2.atoms是全局性的
3.atoms以小写字母开头,后面跟上数字,字符,下划线,或“@”。
4.atoms可以用单引号引起来,使用这种形式后可以创建大写字符开头的atoms,或者包含非数值字符的atoms,例如’Monday’, ’Tuesday’, ’+’, ’*’, ’an atom with spaces’。
5.atoms的值只是atom。
4.Booleans
1.在Erlang中没有独立的booleans类型。所以用原子的true和false来代替booleans。
2.operation:
1. and Returns true only if both arguments are true.
2.andalso Shortcut evaluation of and:return false if the first argument id false,without evaluating the second.
3.or Returns true if either of the arguments is true.
4.orelse Shortcut evaluation of or:returns true if the first argument is true,without evaluating the second.
5.xor returns true if one of its arguments is true and the other false.
6.not Unary negation operator:returns true if its argument is false,and vice versa.