erlang 符号相关基本语法
http://blog.csdn.net/anghlq/article/details/6803332
ErLang语法约定:
- 大写字母开头的名字(比如Address),表示一个变量,包括参数、局部变量等;
- 小写字母开头的单词(比如ok),表示一个常量,叫做atom(原子的意思),包括常量名、函数名、模块名等。
- ErLang的注释用%开头。ErLang用下划线“_”表示任意变量,类似于Java的switch语法里面的default选项。
- 参数中没使用到的变量用下杠和首字母大写,如_Sample
比较符
| op | Description |
| == | equal to |
| /= | not equal to |
| =< | less than or equal to |
| < | less than |
| >= | greater than or equal to |
| > | greater than |
| =:= | exactly equal to |
| =/= | exactly not equal to |
1> 1==1.0.
true
2> 1=:=1.0.
false 运算符
| op | Description | Argument type |
| + | unary + | number |
| - | unary - | number |
| + | number | |
| - | number | |
| * | number | |
| / | floating point division | number |
| bnot | unary bitwise not | integer |
| div | integer division | integer |
| rem | integer remainder of X/Y | integer |
| band | bitwise and | integer |
| bor | bitwise or | integer |
| bxor | arithmetic bitwise xor | integer |
| bsl | arithmetic bitshift left | integer |
| bsr | bitshift right | integer |
7> 2#10 band 2#01.
0
8> 2#10 bor 2#01.
3
Boolean表达式
| op | Description |
| not | unary logical not |
| and | logical and |
| or | logical or |
| xor | logical xor |
短路表达式
Expr1 orelse Expr2
Expr1 andalso Expr2
case A >= -1.0 andalso math:sqrt(A+1) > B of
列表表达式
++
--
1> [1,2,3]++[4,5].
[1,2,3,4,5]
2> [1,2,3,2,1,2]--[2,1,2].
[3,1,2]
二进制表达式
<<>>
<<E1,...,En>>
Ei = Value |
Value:Size |
Value/TypeSpecifierList |
Value:Size/TypeSpecifierList
- TypeSpecifierList
- Type= integer | float | binary | bytes |bitstring | bits | utf8 | utf16 | utf32
- Signedness= signed | unsigned
- Endianness= big | little | native
- Unit= unit:IntegerLiteral
11> <<G,H/bitstring>> = <<1,17,42:12>>.
<<1,17,1,10:4>>
12> H.
<<17,1,10:4>>
13> <<1024/utf8>>.
<<208,128>>
- 赋值时注意增加空格 B=<<1>> 会变成语法错误,因为跟比较符号=<冲突、、
<<"--\r\n", Data/binary>>,
strchr(Bin, C, I) ->
case Bin of
<<_X:I/binary>> ->
0;
<<_X:I/binary, C, _Rest/binary>> ->
I+1;
_ ->
strchr(Bin, C, I+1)
end.
parse_boolean(Value) ->
case Value of
true -> true;
false -> false;
<<"true">> -> true;
<<"false">> -> false;
<<"1">> -> true;
<<"0">> -> false;
1 -> true;
0 -> false
end.
<<N1:32/integer, N2:32/float>> = Bin.
<< PointID:32/unsigned-little-integer, Value:32/little-float>> = Bin.
case Packet of
<<Len:16, PayLoad:Len/binary, 16#ef>> ->
{body, PayLoad};
_ ->
{error, invalid_packet}
end.
case Info of
<<"get ",Str1/bitstring>>->
io:format("case0:~s~n", [binary_to_list(Str1)]);
<<1:1,Str1/bitstring>>->
io:format("case1:~s~n", [Str1])
end.
erlang 符号相关基本语法的更多相关文章
- -bash: 未预期的符号 `(' 附近有语法错误
[1]问题现象 -bash: 未预期的符号 `(' 附近有语法错误 [2]解决方案 给括号前面加反斜杠即可 Good Good Study, Day Day Up. 顺序 选择 循环 总结
- Erlang使用相关笔记
#从源码编译安装Erlang 1. wget http://www.erlang.org/download/otp_src_r16b.tar.gz -p /usr/local/src 2. tar z ...
- WinDbg常用命令系列---符号相关命令
ld (Load Symbols) ld命令加载指定模块的符号并更新所有模块信息. ld ModuleName [/f FileName] 参数: ModuleName指定要加载其符号的模块的名称.m ...
- MVC4相关Razor语法浅谈
1._LayOut.cshtml 文件为mvc的布局文件,里面包函的是htm的静态文件,作为mvc其他view的基础母版使用,子视图要不想想调用它只需在页面设置@{Layout=null;}即可,现对 ...
- MVC4相关Razor语法以及Form表单
Razor的布局(Layout) 默认建的工程都自带的了一个_ViewStart.cshtml文件,文件里面的代码如下: @{ Layout = "~/Views/Shared/_Layou ...
- erl_0011 erlang 定时器相关
转自:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=20764167&id=4470124 3.1 The time ...
- oracle linux下oracle 10g启动EM、isqlplus及相关命令语法
转载:http://hancang2000.blog.sohu.com/139239421.html ORACLE_HOME/bin/emctl start dbconsole $ORACLE_HOM ...
- MVC4相关Razor语法以及Form表单(转载)
Razor的布局(Layout) 默认建的工程都自带的了一个_ViewStart.cshtml文件,文件里面的代码如下: @{ Layout = "~/Views/Shared/_Layou ...
- Python 3 re模块3个括号相关的语法
(?aiLmsux) (One or more letters from the set 'a', 'i', 'L', 'm', 's', 'u', 'x'.) The group matches t ...
随机推荐
- 00087_File
1.IO概述 (1)要把数据持久化存储,就需要把内存中的数据存储到内存以外的其他持久化设备(硬盘.光盘.U盘等)上: (2)当需要把内存中的数据存储到持久化设备上这个动作称为输出(写)Output操作 ...
- 【Codeforces Round #450 (Div. 2) C】Remove Extra One
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举删除第i个数字. 想想删掉这个数字后会有什么影响? 首先,如果a[i]如果是a[1..i]中最大的数字 那么record会减少1 ...
- Android Material风格的应用(一)--AppBar TabLayout
打造Material风格的Android应用 Android Material风格的应用(一)--AppBar TabLayoutAndroid Material风格的应用(二)--RecyclerV ...
- iOS_04_数据类型、常量、变量
一.数据 1.什么是数据 * 生活中时时刻刻都在跟数据打交道,比如体重数据.血压数据.股价数据等.在我们使用计算机的过程中,会接触到各种各样的数据,有文档数据,图片数据,视频数据,还有聊天QQ产生的文 ...
- 关于PyYAML报错问题解决
转自:http://www.fwqtg.net/%E5%85%B3%E4%BA%8Epyyaml%E6%8A%A5%E9%94%99%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86% ...
- Java 泛型-泛型类、泛型方法、泛型接口、通配符、上下限
泛型: 一种程序设计语言的新特性,于Java而言,在JDK 1.5开始引入.泛型就是在设计程序的时候定义一些可变部分,在具体使用的时候再给可变部分指定具体的类型.使用泛型比使用Object变量再进行强 ...
- Machine Learning With Spark学习笔记(提取10万电影数据特征)
注:原文中的代码是在spark-shell中编写运行的,本人的是在eclipse中编写运行,所以结果输出形式可能会与这本书中的不太一样. 首先将用户数据u.data读入SparkContext中.然后 ...
- Nginx- 实现跨域访问
https://blog.csdn.net/m_nanle_xiaobudiu/article/details/80688740
- MHA 一主两从搭建-keepalived-手动切换
环境介绍:主机名 IP MHA角色 MySQL角色node1 192.168.56.26 Node MySQL Master node2 192.168.56.27 Node MySQL Master ...
- 23种设计模式——Prototype模式
Prototype模式是提供自我复制的功能.包括浅拷贝和深拷贝. 一.Prototype模式的用途 场景1:游戏场景中有很多类似的敌人,它们的技能都一样,但是随着敌人出现的位置和不同,它们的能力也不太 ...