字符串是双引号,单引号的是atom
元组:atom
下标从1开始 X = {'test1',2,3,4}. element(1,X). 配合模式匹配,能够给元素项命名,直接不用下标标记元素项
列表增删改查spa
增长: 经过管道符号,把左边的数据添加到右边的列表 [5,4,3|[1,2]]. 两个列表经过 ++ 生成新列表 [1,2,3,4] ++ [7,8,9,10]. 删除: 大列表--小列表,固然是生成新变量了 [1,2,3,4,5,6,7,8] -- [1,2,3,4]. 修改: erlang变量不能够修改,所以,无 赋值: [X,Y|P] = [1,2,3,4,5,6,7,8].
大小比较:(毁三观啊)code
数值 < 原子 < 元组 < 列表
比较运算符orm
>= =< (不能像箭头,得像苦逼的脸)
if语句blog
-module(test_erlang). -export([test/1]). test(X)-> if X == 0 -> io:format("asdasd"); X == 10 -> io:format("10 if ~p.~n",X); true -> io:format("ok") end.
case语句element
-module(test_erlang). -export([test/1]). test(X)-> case X of 0 -> io:format("asdasd"); 10 -> io:format("10 if ~p.~n",X); Other -> io:format("ok") end.