###运行方式
- erl => c(test).=> test.foo("jack").
- escript sp.erl 5
- escript.exe sp.erl 5(window)
- erlc hello.erl => erl -noshell -s hello start -s init stop
###数据结构
- atom ,string,[A|T],{a,b,c}, <<>>, 宏
- 数字,(进制2#101).
- dict:new()模块实现map.
- {lists,map}调用map方法.
- %%注释
###表达式
- if a -> b; c->d end .
- case s of a->b;c->d end.
- try a of b->d; e->f catch g->h; i->j; after .. end.
- receive a->b; c->d end.
- when 防卫断言
- [ X || X <- [1,2,3] ]
###函数,没有for,用递归
- B = fun(B)->B+2 end.
- apply(Mod, Func, Args)
- fun say/1
- lists:map(fun say/1,lists:seq(1,10)).
- lists:filter
- io:format("
wn",[X]). == print
###模块 -module(tu) -import(tu,[a,b]) -compile(export_all) -export([say/1]) -file("/Users/Francesco/records1.erl", 1). -record(name,{first,surname}). * #name{first="jack",surname="tomas"}. * rr(sp). => rl().=> rf().
-define(mar(X),{a,X}).
- ?mar(3).
- ?MODULE
- ?FILE
- ?LINE
###BIFs内建函数 date() time() length([1,2,3,4,5]) size({a,b,c}) atom_to_list(an_atom) list_to_tuple([1,2,3,4]) integer_to_list(2234) tuple_to_list({}) hd(L) 返回列表L的第一个元素 tl(L) 返回列表L的最后一个元素