Erlang
文章平均质量分 71
柒上网络
这个作者很懒,什么都没留下…
展开
-
erlang lists 系列函数功能与用法详解(共68个函数)
一,带函数Pred1, all(Pred, List) -> boolean()如果List中的每个元素作为Pred函数的参数执行,结果都返回true,那么all函数返回true,否则返回false例子:lists:all(fun(E) -> true end,[1,2,3,4]).结果true2, any(Pred, List) -> boolean()转载 2012-08-06 14:03:16 · 1222 阅读 · 0 评论 -
Erlang 中lists的用法详解和例子说明,详细 全
-。- 收集的。官方doc也不尽详细呢。。一,带函数Pred1, all(Pred, List) -> boolean()如果List中的每个元素作为Pred函数的参数执行,结果都返回true,那么all函数返回true,否则返回false例子:lists:all(fun(E) -> true end,[1,2,3,4]).结果true2,原创 2012-08-10 11:17:32 · 6153 阅读 · 0 评论 -
[集]erlang常用函数收集
1、消重算法:1> List = [1,2,3,1,2,4]. [1,2,3,1,2,4] 2> sets:to_list(sets:from_list(List)). [3,2,1,4] 2、排序算法:3>lists:sort(List).[1,1,2,2,3,4] 根据某一元素排序4>rd(app{id,date,pk原创 2012-08-10 13:31:51 · 1434 阅读 · 0 评论 -
erlang 并发编程,spawn 创建新的进程
1. Pid = spawn(Fun) 创建并发进程对Fun求值,新创建的进程和调用者所在进程并发运行。 可以向新创建的进程Pid发送消息 Pid!M. 或者想多个进程发送消息 Pid1 ! Pid2 !...Pidn ! M . !号为发送消息运算符 注意:消息的发送是异步的,直接返回消息本身。 接受发送给当前进程的消息语法:receive原创 2012-08-10 11:50:41 · 6392 阅读 · 0 评论 -
erlang内置大数据量数据库 ets,dets 初窥 .
ets是Erlang term storage的缩写, dets则是disk ets. 它们不同的就是ets存在内存里面,而dets则存在磁盘上。ets存的数据表是暂时性的,拥有它的进程挂了,它也会挂掉. dets就算程序完成或者挂了,数据表还是持久存在的.如果是异常退出的, 可以进行修复.ets表看起来像是由erlang实现的,但实际上它是由运行时系统实现的,所以具有更高原创 2012-08-09 10:20:58 · 2686 阅读 · 0 评论 -
Erlang中 基本服务器代码解析
%%server1.erl:-module(server1)-export([start/2,rpc/2])start(Name,Mod)-> register(Name,spawn(fun()->loop(Name,Mod,Mod:init())end)).rpc(Name,Request)-> Name!{self(),Request},原创 2012-08-08 10:49:05 · 1016 阅读 · 0 评论 -
Erlang gen_server:start_link/3 和gen_server:start_link/4 的区别以及各参数的含义
两个方法都可以用来启动一个gen_server服务器进程,具体的参数如下: gen_server:start_link(Module,Args,Option); gen_server:start_link(ServerName,Module,Args,Option); 第二个方法只比第一个多了个Serv原创 2012-08-08 10:38:11 · 2458 阅读 · 0 评论 -
OTP中supervisor启动过程
从rabbit_sup模块开始看起:rabbit_sup模块的start_link是被rabbit app模块的start/2方法所调用的rabbit.erl文件: start(normal, []) ->{ok, SupPid} = rabbit_sup:start_link(),rabbit_sup.erl文件:-define(SERVER,原创 2012-08-07 17:55:08 · 2275 阅读 · 0 评论 -
erlang 几个 behaviour 的简单小总结
应用erlang的behaviour 框架(gen_server,gen_fsm,gen_event,supervisor)在处理很多情况的时候省下大量不必要的代码,使用的时候在框架基础添加自定义逻辑就可以搭建项目了,可以说是精髓。gen_server:提供的是client和server之间,请求和回调的处理。 Client --请求-->Server Serv原创 2012-08-07 15:04:12 · 1931 阅读 · 1 评论 -
erlang开发环境配置-支持中文的ide Erlang如何安装和配置 附图详解
从接触学习和使用erlang至今已经有一年多了,刚开始erlang的开发环境都是直接copy的别人装好erlide的eclipse,最近看了一下erlide的官网学习了一下ecplise安装erlide插件的。 首先,下载必须安装的东西,Eclipse , Java and Erlang OPT 。1 下载最新的erlang otp,从官网下载http://www.erlang.原创 2012-08-06 18:53:35 · 3848 阅读 · 2 评论 -
erlang behaviour小结之gen_server OTP入门
首先清楚gen_server提供C/S架构中的服务端的实现,即定义了自己一套规范的服务器框架。 在以上基础上,具体学习下gen_server的实现过程。先是定义模块的行为模式为gen_server[plain] view plaincopyprint?-module(lq原创 2012-08-06 18:55:46 · 1661 阅读 · 0 评论 -
对Erlang开发者的几点建议
* 确保没有任何编译警告* Erlang中String采用list实现,32位系统中,其1个字符用8个字节的空间(4个保存value, 4个保存指针)。因此string速度较慢,空间占用较大* 在Server中,总是尽力书写尾递归(tail-recursive)的函数* 使用'++'时,left list会被拷贝,然后添加到right list的头部,因此最好把length转载 2012-08-06 17:03:07 · 1186 阅读 · 0 评论 -
erlang app程序打包及启动流程 .
我们写完一组功能模块后(在erlang中,以module为单位),总是希望这一组模块,可以打包成一个应用,作为一个单独的整个,可以启动,停止,象 mnesia一样。并可以在其它应用中引用。如何来做到这一点呢。每一个应用都是通过application:start系列函数来启动,application:stop可以停止一个应用。 一个应用需要一个.app文件来描述,主要描述它包括哪些文件,参数等。转载 2012-08-06 14:11:53 · 3336 阅读 · 0 评论 -
Erlang开发建议
以下是在erlang项目开发中的一些记录,即包含很多通俗易懂的原则,也包含一些似是而非的建议,比较混乱,还没有积累到一个可以分门别类的地步,各位就将就看吧.. :) * 确保没有任何编译警告 * Erlang中String采用list实现,32位系统中,其1个字符用8个字节的空间(4个保存value, 4个保存指针)。因此string速度较慢,空间占用较大 * 在Ser转载 2012-10-09 17:50:15 · 2598 阅读 · 0 评论