随笔分类 - erlang:初级
摘要:以java和erlang为例:①、java:面向对象 且 存在return。②、erlang: 函数性编程 不存在return%% 模拟检测 多个输入信息是否合理,只要有一个不合理,则返回。%% 举例:UName,UEmail,UPass,USex,UMoney,UOwn.%% 以上述描述的顺序为检...
阅读全文
摘要:inets模块MODULE SUMMARYThe inets services API。inets:start():启动应用。
阅读全文
摘要:详情请参考官网:http://www.erlang.org/doc/reference_manual/records.htmlhttp://www.erlang.org/doc/programming_examples/records.html1. record本质上是tuple.2.获取recor...
阅读全文
摘要:验证erlang官网提供的思想:record的修改是复制。-module (test_record).-record (record_5,{ aa1 = 0, aa2 = 0, aa3 = 0, aa4 = 0, aa5 = 0}).-record(record_50...
阅读全文
摘要:一、计算机的随机数的老问题,伪随机数。 random:seed() random:uniform(N) 如果seed是相同的,则第M次执行 random:uniform(N) 、M、N相同,则得到的随机数也是相同的。
阅读全文
摘要:官方链接:http://erlang.org/doc/man/supervisor.html http://erlang.org/doc/design_principles/sup_princ.htmlThe supervisor is responsible for starting, stopping and monitoring its child processes. The basic idea of a supervisor is that it should keep its child processes alive by restarting them when ne...
阅读全文
摘要:转自:http://www.roberthorvick.com/2009/07/08/syntax-highlighing-for-erlang-in-notepad/Syntax Highlighing for Erlang in NotePad++Update: The definition has been updated to include support for atoms, variables and function names as well as additional file extensions. Screen shot and downloadable content
阅读全文
摘要:1.exit(Pid,Reason)貌似不会引起gen_server的terminate()的执行。猜测依据:erlang编程指南的第十二章的272页终止 当从 回调函数中的一个收到stop结果时(init除外),或当捕获存在而发生了异常进程终止时,就会触发terminate(Reason,LoopData)回调函数。在terminate/2中,你可以取消在init/1中所做的事情。这将忽略它的返回值。
阅读全文
摘要:https://github.com/rvirding/luerl
阅读全文
摘要:转自:http://www.cnblogs.com/futuredo/archive/2012/10/26/2737644.htmlFunctions1 Pattern matching模式匹配Pattern matching in function head and incaseandreceiveclauses are optimized by the compiler. With a few exceptions, there is nothing to gain by rearranging clauses.函数头以及case和receive子句中的模式匹配是经过编译器优化的。重新整理
阅读全文
摘要:转自:http://www.cnblogs.com/futuredo/archive/2012/10/19/2727204.htmlConstructing and matching binariesErlang/OTP R15B02In R12B, the most natural way to write binary construction and matching is now significantly faster than in earlier releases.在R12B版本中,构造和匹配二进制数据最自然的方式,相比较之前的版本其效率有了明显提高。To construct a
阅读全文
摘要:转自:http://www.cnblogs.com/futuredo/archive/2012/10/17/2726416.htmlCommon Caveats(常见注意事项)Erlang/OTP R15B02 Here we list a few modules and BIFs to watch out for, and not only from a performance point of view. 这里我们列出了需要注意的一些模块和内置函数,不仅仅是从性能的角度来看。 1 The timer module 定时器模块 Creating timers usingerlang...
阅读全文
摘要:转自:http://www.cnblogs.com/futuredo/archive/2012/10/16/2725770.htmlThe Eight Myths of Erlang PerformanceErlang/OTP R15B021 Myth: Funs are slow Fun函数很慢(这里应该是指Module:Function(Arguments)这种形式的函数,其中M,F,A可以是变量类型,值不是固定的) Yes, funs used to be slow. Very slow. Slower thanapply/3. Originally, funs were imple..
阅读全文
摘要:转自:http://www.cnblogs.com/futuredo/archive/2012/10/22/2734186.htmlList handling1 Creating a list创建一个列表Lists can only be built starting from the end and attaching list elements at the beginning. If you use the++operator like this列表只能从尾端开始创建,从头部加入元素。如果你像这样使用++操作符List1 ++ List2you will create a new lis
阅读全文
摘要:一、使用spawn(Fun)生成新的进程,在Fun中调用ets:new(Arg),在new()后能查到新的ets表的信息,但是在别的进程以及控制台都查不到该ets表的信息。原因:普通的spawn()生成的进程执行完任务后就会自动关闭了,由于进程的关闭由该进程创建的ets表也会随之关闭。
阅读全文
摘要:转自:http://blog.csdn.net/flyinmind/article/details/7740540项目中用到erlang,同时也用到mysql。惯例,google。但是,按照网上说的做,有些出入,行不通,需要自己摸索,下面记录我摸索的东西。1、下载erlang-mysql-driver;下载地址:https://github.com/dizzyd/erlang-mysql-driver2、解压到mysql目录,不罗嗦了;3、编译要先配置erlang路径,在/etc/profile中,将erlang的bin路径写入比如PATH=$PATH:/home/erlang/bin否则提示
阅读全文
摘要:https://github.com/Eonblast/Emysqlhttps://github.com/denglf/erlang-db-driverhttps://github.com/dizzyd/erlang-mysql-driver(推荐)https://github.com/Eonbla...
阅读全文
摘要:1> list_to_binary(["select * from aa limit","1",",","97"]).>2> list_to_binary(["select * from aa limit",integer_to_list(1),",","97"]).>3> list_to_binary(["select * from aa limit",1,"97"]). >不理
阅读全文
摘要:一、 catch(Fun):似乎可以避免因为 函数Fun内的错误而造成的当前的进程的崩溃。
阅读全文