erlang

Multiple filters in list comprehension in Erlang

泪湿孤枕 提交于 2019-12-05 21:54:44
Say I have a list that contains weather: 1> Weather = [{toronto, rain}, {montreal, storms}, {london, fog}, {paris, sun}, {boston, fog}, {vancouver, snow}]. To get foggy places, I could do this: 2> FoggyPlaces = [X || {X, fog} <- Weather]. [london,boston] Now I want to retrieve places that are both foggy and snowy. I tried this, but it retrieves only snowy places, 3> FoggyAndSnowyPlaces = [X || {X, fog} <- Weather, {X,snow} <- Weather]. [vancouver,vancouver] where I was expecting [london,boston,vancouver] . How can I include multiple filters? FoggyAndSnowyPlaces = [X || {X, Y} <- Weather, (Y ==

Should I use try catch in Erlang or should I pass back an error token?

≡放荡痞女 提交于 2019-12-05 21:01:49
I'm coding in Erlang and a I am bit unsure about how to approach error handling, especially after seeing the ugly errors Erlang always returns. Should I use try catch in Erlang or should I pass back an error token? There are three basic ways to do exception handling in sequential Erlang: throws ( throw(Term) ) errors ( erlang:error(Reason) ) exits ( exit(Reason) ) Throws are to be used for non-local returns and some kinds of exception you expect to be able to handle (maybe because they occur often). When that one is raised, you should try and stop it before it gets outside your module. The

RabbitMQ消息中间件-安装(windows)

六眼飞鱼酱① 提交于 2019-12-05 20:52:49
一.下载 1.下载RabbitMQ http://www.rabbitmq.com/download.html 2.下载Erlang http://erlang.org/downloads RabbitMQ对Erlang版本的对应 二、 安装 1.安装 Erlang Erlang 安装完成 2. 安装 RabbitMQ RabbitMQ安装完成 启用管理工具 输入命令:rabbitmq-plugins enable rabbitmq_management 访问 http://localhost:15672/ 账号:guest 密码:guest 如果不能访问: C:\Users\angle\AppData\Roaming\RabbitMQ\db 里面的数据删除 再次安装一下Rabbitmq.exe; 注: 文件夹为隐藏 需要再文件夹选项中把隐藏文件夹打开显示 然后再执行 rabbitmq-plugins enable rabbitmq_management 来源: https://www.cnblogs.com/angel-devil/p/11937408.html

binary format, bitwise operations exist? eg. <<16#7F, 16#FF>> bsl 1

ⅰ亾dé卋堺 提交于 2019-12-05 20:44:07
问题 In erlang, there are bitwise operations to operate on integers, for example: 1&gt 127 bsl 1. 254 there is also the ability to pack integers into a sequence of bytes &lt&lt 16#7F, 16#FF &gt&gt is it possible, or are there any operators or BIFs that can perform bitwise operations (eg AND, OR, XOR, SHL, SHR) on binary packed data? for example (if bsl worked on binary packages - which it does not): 1&gt &lt&lt 16#7F, 16#FF &gt&gt bsl 1. &lt&lt 255, 254 &gt&gt 回答1: Try out this way: bbsl(Bin,Shift

Starting the erlang VM without epmd

假如想象 提交于 2019-12-05 20:18:36
I'm trying to startup epmd separately from the erlang vm, in order to do monitoring on the connection handling. This works fine, except for cases when the vm starts up before epmd. Is there a way to make the erlang vm start without it starting the epmd on its own? marcelog Possible helpful questions/answers: Is there a way to stop Erlang servers from automatically starting epmd? Ensure epmd started So inline with those questions/answers, I'd suggest to make the erlang vm service depend on epmd (which should be another service on its own). Also, if you run epmd as one of your very first

Erlang's maximum number of simultaneous open ports?

左心房为你撑大大i 提交于 2019-12-05 20:13:49
问题 Does the erlang TCP/IP library have some limitations? I've done some searching but can't find any definitive answers. I have set the ERL_MAX_PORTS environment variable to 12000 and configured Yaws to use unlimited connections. I've written a simple client application that connects to an appmod I've written for Yaws and am testing the number of simultaneous connections by launch X number of clients all at the same time. I find that when I get to about 100 clients, the Yaws server stops

Erlang语言研究综述

时间秒杀一切 提交于 2019-12-05 20:03:33
摘 要 : 本文前半部分主要是关于Erlang编程语言相关的内容;着重就一般学习编程语言的一般的关注点来阐述了Erlang编程语言的基本语法点,主要包括:Erlang的变量、Erlang的数据类型、Erlang的语句和Erlang编程语言的函数与模块四个方面;本文的后半部分主要就Erlang语言的并行化编程的实践:Erlang的并行化编程与Erlang并行化编程在矩阵乘积的实际应用,通过实践,可以发现,Erlang语言确实在并行化编程方面表现得很优秀。 关键词 :并行计算;Erlang;编程语言;矩阵相乘 自从计算机出现的时候开始,其就迅速发展。短暂的几十年,计算机已经从当初的单核走过,向多核发展,直到现在的多机系统。提升计算机的计算性能和计算速率一直是计算机发展的不变的主题,但是随着单位面积晶体管数目的饱和,单纯的以晶体管的数目来衡量计算机的发展水平已经成为过去,单纯地以增加单位面积晶体管的数目来提升计算的性能已经走到了尽头,就像C++标准委员会主席Herb Sutter所说的那样我们的《免费的午餐已经结束》,计算机的发展开始向着多核的方向发展,但是为了达到一定的计算速率,仅仅是依靠多核来提升的代价是昂贵的,且依靠这样的方式有一定的局限性。为了节省成本与得到更大的计算性能,多机系统逐渐出现。利用多个一般的计算核心来组成计算机集群进行并行计算或分布式计算来提升计算的能力

centos 6.8 源码安装 erlang/otp 19.0.2

随声附和 提交于 2019-12-05 19:53:12
最近一直都是在debian jessie下开发erlang代码,但部署环境一直都是在centos 6上面,发现centos 6系列的软件版本还是比较落后的, 但centos的健壮性的确很好。所以开始了在centos 6.8下面源码安装 erlang/otp 19.0.2版本。 后来,特意查了一下centos 6的发布时间,原来RHEL 6 发布在2010年,现在有6年历史了。另外RHEL 有10年支持,3年额外支持。强大的不是一点点。 首先从github下面下载erlang/otp 19.0.2源码包: wget -c https://github.com/erlang/otp/archive/OTP-19.0.2.tar.gz 安装依赖: yum groupinstall -y "Development Tools" yum install build-essential m4 openssl openssl-devel unixODBC \ unixODBC-devel make gcc gcc-c++ kernel-devel m4 ncurses-devel yum install java-1.8.0-openjdk-devel java-1.8.0-openjdk-headless \ java-1.8.0-openjdk-javadoc java-1.8.0

centos7的rabbitmq升级到3.7.10集群

放肆的年华 提交于 2019-12-05 19:51:18
centos7的rabbitmq升级到3.7.10集群 #卸载 [root@linux-node1 ~]# systemctl stop rabbitmq-server [root@linux-node1 ~]# yum remove rabbitmq-server -y [root@linux-node1 yum.repos.d]# yum remove erlang* -y [root@linux-node1 ~]# rm -rf /var/lib/rabbitmq/ 1 安装erlang curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash yum install erlang -y 查看版本: erl 3.安装rabbitmq(当前目录为rabbitmq-server-3.7.10-1.el7.noarch.rpm包的目录下) [root@linux-node1 ~]#wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.10/rabbitmq-server-3.7.10-1.el7.noarch.rpm [root@linux-node1 ~]

Erlang并发机制 –进程调度

房东的猫 提交于 2019-12-05 19:49:03
Erlang调度器主要完成对Erlang进程的调度,它是Erlang实现软件实时和进程之间公平使用CPU的关键。Erlang运行时,有4种任务需要被调度:进程, Port , Linked-in driver ,Erlang虚拟机的系统级活动。 Erlang调度器主要有以下特点: 1. 进程调度运行在用户空间 :Erlang进程不同于操作系统进程,Erlang的进程调度也跟操作系统完全没有关系,是由Erlang虚拟机来完成的; 2. 调度是抢占式的:每一个进程在创建时,都会分配一个固定数目的reduction(R15B中,这个数量默认值是2000),每一次操作(函数调用),reduction就会减少,当这个数量减少到0时或者进程没有匹配的消息时,抢占就会发生(无视优先级); 3. 每个进程公平的使用CPU:每个进程分配相同数量的reduction,可以保证进程可以公平的(不是相等的)使用CPU资源 4. 调度器保证软实时性:Erlang中的进程有优先级,调度器可以保证在下一次调度发生时,高优先级的进程可以优先得到执行。 Reduction 受操作系统中基于时间片调度算法的影响,一开始知道有reduction这个概念时,一直想搞清楚这个reduction到底对应多长的绝对时间,不过,从Erlang本身对reduction的使用来看,完全没有必要纠结这个问题。《Erlang编程指南