123 表示数字 '123' 表示原子 "123"表示列表
whereis(RegName) -> pid() | port() | undefined Returns the pid or port identifier with the registered name RegName
unregister(RegName) -> true
Removes the registered name RegName, associated with a pid or a port identifier.
time() -> Time {Hour, Minute, Second}.
now() -> Timestamp { MegaSecs, Secs, MicroSecs }
localtime() -> DateTime {{Year, Month, Day}, {Hour, Minute, Second}}
throw(Any) -> no_return()
catch throw({hello, there}). // {hello,there}
Failure: nocatch if not evaluated within a catch.
Bin = term_to_binary(Tuple). // <<131,104,3,100,0,1,97,100,0,1,98,100,0,1,99>>
binary_to_term(Bin). // {a,b,c}
statistics(wall_clock). // 统计 运行时间
erlang:start_timer(Time, Dest, Msg) -> TimerRef
Starts a timer which will send the message {timeout,..} to Dest after Time milliseconds.
erlang:send_after(Time, Dest, Msg) -> TimerRef
Starts a timer which will send the message Msg to Dest after Time milliseconds.
split_binary(Bin, Pos) -> {binary(), binary()}
list_to_binary("0123456789").
{B1, B2} = split_binary(B,3). -> B1 = <<"012">>.
插入新元素到元组中
insert_element(2, {one, two, three}, new). -> {one,new,two,three}
append_element({one, two}, three). -> {one,two,three}
element(1, {a,b,[c,d]}) -> a 获取元组的第1个元素
tuple_size({a, b, {c,d}}). -> 3
is_tuple({}) -> true is_tuple(a) -> false
is_atom(Term)
is_binary(Term)
is_bitstring(Term)
is_function(Term) -> boolean()
is_list(Term) -> boolean()
is_integer(Term) -> boolean() 等 is_xxx 函数
float(55). -> 55.0
round(5.5) -> 6
tuple_to_list({a, b, [c, d]}). -> [a,b,[c,d]]
list_to_tuple([a, b, {d, e}]). -> {a,b,{d,e}}
list_to_integer("123"). -> 123
list_to_integer("3FF", 16). -> 1023
integer_to_list(13). -> "13" 注意 不能用 13.0 bad argument异常
integer_to_binary(77). -> <<"77">>
binary_to_integer(<<"123">>). -> 123
binary_to_integer(<<"3FF">>, 16). -> 1023
list_to_float("1.34"). -> 1.34 注意使用 "1"作为参数 bad argment异常
float_to_list(1.34) -> "1.34000000000000007994e+00"
float_to_binary(7.12, [{decimals, 4}]). -> <<"7.1200">>
float_to_binary(7.12, [{decimals, 4}, compact]). -> <<"7.12">>
atom_to_list(abc). -> "abc"
list_to_atom([1,2,3]) -> '\001\002\003' 但[a,b,c] 则 bad argument异常
list_to_atom([$1,$2,$3]) -> '123'
list_to_binary([1,2,3]) -> <<1,2,3>> 但[a,b,c] 则 bad argument异常
list_to_binary([$1,$2,$3]) -> <<"123">>. <<1,2,3>> 不等同于 <<"123">>
list_to_bitstring([1,2,3]) -> <<1,2,3>> 但[a,b,c] 则 bad argument异常
list_to_bitstring([$1,$2,$3]) -> <<"123">>.
正确的用法 list_to_atom([$a,$b,$c]).
binary_to_term(Binary) -> term()
hd([a,b,c]) -> a
tl([a,b,c]). -> [b,c]. 返回tail 部分, 空列表 bad argument异常
length([a,c,b]) -> 3
spawn(Fun) -> pid()
spawn(Node, Fun) -> pid()
spawn(Module, Function, Args) -> pid()
spawn(Node, Module, Function, Args) -> pid()
spawn_link(Module, Function, Args) -> pid()
spawn_link(Node, Module, Function, Args) -> pid()
exit(Reason) -> no_return()
Stops the execution of the calling process with the exit reason Reason
catch exit(foobar). -> {'EXIT',foobar}
exit(Pid, Reason) -> true
Sends an exit signal with exit reason Reason to the process or port identified by Pid.
link(PidOrPort) -> true
Creates a link between the calling process and another process (or port)
unlink(Id) -> true
Removes the link, if there is one, between the calling process and the process or port referred to by Id.
register(RegName, PidOrPort) -> true
registered() -> [RegName]
processes() -> [pid()] Returns a list of process identifiers corresponding to all the processes currently existing on the local node.
purge_module(Module) -> true
Removes old code for Module. Before this BIF is used, erlang:check_process_code/2 should be called to check that no processes are executing old code in the module.
erlang:loaded() -> [Module]
Returns a list of all loaded Erlang modules (current and/or old code)
erlang:send(Dest, Msg) -> Msg 等同于 Dest ! Msg
self() -> pid()
nodes() Returns a list of all visible nodes in the system, excluding the local node
node() -> Node Returns the name of the local node.
进程字典相关函数:
put(name, sky).
put(sex, 1).
get() -> [{Key, Val}]
get(name) -> sky
erase(name).
erase().
whereis(RegName) -> pid() | port() | undefined Returns the pid or port identifier with the registered name RegName
unregister(RegName) -> true
Removes the registered name RegName, associated with a pid or a port identifier.
time() -> Time {Hour, Minute, Second}.
now() -> Timestamp { MegaSecs, Secs, MicroSecs }
localtime() -> DateTime {{Year, Month, Day}, {Hour, Minute, Second}}
throw(Any) -> no_return()
catch throw({hello, there}). // {hello,there}
Failure: nocatch if not evaluated within a catch.
Bin = term_to_binary(Tuple). // <<131,104,3,100,0,1,97,100,0,1,98,100,0,1,99>>
binary_to_term(Bin). // {a,b,c}
statistics(wall_clock). // 统计 运行时间
erlang:start_timer(Time, Dest, Msg) -> TimerRef
Starts a timer which will send the message {timeout,..} to Dest after Time milliseconds.
erlang:send_after(Time, Dest, Msg) -> TimerRef
Starts a timer which will send the message Msg to Dest after Time milliseconds.
split_binary(Bin, Pos) -> {binary(), binary()}
list_to_binary("0123456789").
{B1, B2} = split_binary(B,3). -> B1 = <<"012">>.
插入新元素到元组中
insert_element(2, {one, two, three}, new). -> {one,new,two,three}
append_element({one, two}, three). -> {one,two,three}
element(1, {a,b,[c,d]}) -> a 获取元组的第1个元素
tuple_size({a, b, {c,d}}). -> 3
is_tuple({}) -> true is_tuple(a) -> false
is_atom(Term)
is_binary(Term)
is_bitstring(Term)
is_function(Term) -> boolean()
is_list(Term) -> boolean()
is_integer(Term) -> boolean() 等 is_xxx 函数
float(55). -> 55.0
round(5.5) -> 6
tuple_to_list({a, b, [c, d]}). -> [a,b,[c,d]]
list_to_tuple([a, b, {d, e}]). -> {a,b,{d,e}}
list_to_integer("123"). -> 123
list_to_integer("3FF", 16). -> 1023
integer_to_list(13). -> "13" 注意 不能用 13.0 bad argument异常
integer_to_binary(77). -> <<"77">>
binary_to_integer(<<"123">>). -> 123
binary_to_integer(<<"3FF">>, 16). -> 1023
list_to_float("1.34"). -> 1.34 注意使用 "1"作为参数 bad argment异常
float_to_list(1.34) -> "1.34000000000000007994e+00"
float_to_binary(7.12, [{decimals, 4}]). -> <<"7.1200">>
float_to_binary(7.12, [{decimals, 4}, compact]). -> <<"7.12">>
atom_to_list(abc). -> "abc"
list_to_atom([1,2,3]) -> '\001\002\003' 但[a,b,c] 则 bad argument异常
list_to_atom([$1,$2,$3]) -> '123'
list_to_binary([1,2,3]) -> <<1,2,3>> 但[a,b,c] 则 bad argument异常
list_to_binary([$1,$2,$3]) -> <<"123">>. <<1,2,3>> 不等同于 <<"123">>
list_to_bitstring([1,2,3]) -> <<1,2,3>> 但[a,b,c] 则 bad argument异常
list_to_bitstring([$1,$2,$3]) -> <<"123">>.
正确的用法 list_to_atom([$a,$b,$c]).
binary_to_term(Binary) -> term()
hd([a,b,c]) -> a
tl([a,b,c]). -> [b,c]. 返回tail 部分, 空列表 bad argument异常
length([a,c,b]) -> 3
spawn(Fun) -> pid()
spawn(Node, Fun) -> pid()
spawn(Module, Function, Args) -> pid()
spawn(Node, Module, Function, Args) -> pid()
spawn_link(Module, Function, Args) -> pid()
spawn_link(Node, Module, Function, Args) -> pid()
exit(Reason) -> no_return()
Stops the execution of the calling process with the exit reason Reason
catch exit(foobar). -> {'EXIT',foobar}
exit(Pid, Reason) -> true
Sends an exit signal with exit reason Reason to the process or port identified by Pid.
link(PidOrPort) -> true
Creates a link between the calling process and another process (or port)
unlink(Id) -> true
Removes the link, if there is one, between the calling process and the process or port referred to by Id.
register(RegName, PidOrPort) -> true
registered() -> [RegName]
processes() -> [pid()] Returns a list of process identifiers corresponding to all the processes currently existing on the local node.
purge_module(Module) -> true
Removes old code for Module. Before this BIF is used, erlang:check_process_code/2 should be called to check that no processes are executing old code in the module.
erlang:loaded() -> [Module]
Returns a list of all loaded Erlang modules (current and/or old code)
erlang:send(Dest, Msg) -> Msg 等同于 Dest ! Msg
self() -> pid()
nodes() Returns a list of all visible nodes in the system, excluding the local node
node() -> Node Returns the name of the local node.
进程字典相关函数:
put(name, sky).
put(sex, 1).
get() -> [{Key, Val}]
get(name) -> sky
erase(name).
erase().