erlang

Erlang; list comprehension without duplicates

眉间皱痕 提交于 2020-01-16 03:32:10
问题 I am doing somthing horrible but I don't know how to make it better. I am forming all pairwise sums of the elements of a List called SomeList, but I don't want to see duplicates ( I guess I want "all possible pairwise sums" ): sets:to_list(sets:from_list([A+B || A <- SomeList, B <- SomeList])) SomeList does NOT contain duplicates. This works, but is horribly inefficient, because the original list before the set conversion is GIGANTIC. Is there a better way to do this? 回答1: You could simply

Erlang B型公式计算呼损概率

本秂侑毒 提交于 2020-01-16 02:41:17
Erlang B型公式计算呼损概率 背景 公式 MATLAB实现 背景 原由来源于和师兄的对话,如下图。28个人共用4部电话️,与7个人共用1部电话️相比,电话的利用率提高了多少?或每个人能够顺利用上电话的概率提高了多少?每个人平均3小时用1次电话,每次用时5分钟。对于该问题我们把它转化为呼叫损失概率的计算问题。 公式 Erlang B型公适用于M/M/m/m排队系统计算呼叫损失概率,公式参考文献[1]. MATLAB实现 %效率比较-wdl-2020-1-9 %利用爱尔朗B型公式—计算无等待呼叫损失率 % 参考文献 Guoping Zhang,two common properties of the Erlang-B fuction Erlang-C function and % Engset blocking function,2003 % lamda 总体业务到达率 % mu 队列服务速率 % m 队列的数量 % a =lamda/mu % B(a,m)=a^(m)/factorial(m)/(a^(i)/factorial(i),i从0到m的累加和) % 每个人的业务到达率 lamda=1/3;%单位 次/小时 假设每人呼叫业务相互独立 mu=1*60/5;%电话服务速率 1hour/5min %Scene1 28人4部电话 m=4;%电话数量 users=28;

undefined function :wx_object.start/3

岁酱吖の 提交于 2020-01-16 01:10:11
问题 I have tried to install ErLang on my Mac 64bit, Capitan, I've tried to install it via brew, but when I try to run :observer.start I get this error: ** (UndefinedFunctionError) undefined function :wx_object.start/3 (module :wx_object is not available) :wx_object.start(:observer_wx, [], []) observer_wx.erl:72: :observer_wx.start/0 I also tried to install erLang otp 18.3 using erlang solutions, but I got the same error. Any idea? EDIT If I try to start the observer directly from the Erlang shell

Specifying app startup order with erlang.mk

杀马特。学长 韩版系。学妹 提交于 2020-01-16 00:44:31
问题 I'm trying to covert over from an antiquated unmaintained build tool to erlang.mk. I have a release created using erlang.mk, but it fails when starting up, I believe because apps are starting up in the wrong order. How do I specify the startup order of the apps? I would have thought that it would start up apps in the same order as specified in the LOCAL_DEPS variable of the Makefile, but that doesn't seem to be happening. I've looked everywhere I can in the docs, plus googled, but haven't

how to download file by erlang cowboy?

妖精的绣舞 提交于 2020-01-16 00:38:11
问题 I want to download file from the browser and I try to achieve by cowboy, however I failed and the browser show me that "Repeat header received from the server.". I have no idea, everyone please help me. this is my code of handler: ` %% @doc GET echo handler. -module(toppage_handler2). -export([init/3]). -export([handle/2]). -export([terminate/3]). init(_Transport, Req, []) -> {ok, Req, undefined}. handle(Req, State) -> {Method, Req2} = cowboy_req:method(Req), {Echo, Req3} = cowboy_req:qs_val(

Case to check when list is empty rather then recursion?

孤者浪人 提交于 2020-01-15 11:26:14
问题 Im trying to check with a case if a list is empty rather then recursivly catching the pattern when it is, is this the right way to go in Erlang or am i just walking down the wrong path and pattern matching is the best way to catch if a list has been emptied or not? calculate([Head|Tail], pi, x, y) -> ...calculations of Head being sent to a list... case Tail == [] of false -> calculate(Tail, pi, x, y) end. or should i just pattern match on calculate if the list is empty? 回答1: Error in your

Erlang debugger error: Could not find 'wxe_driver.so'

孤者浪人 提交于 2020-01-15 07:48:26
问题 I can see the following error report when I start up the debugger. 2> debugger:start(). =ERROR REPORT==== 23-Jan-2014::11:59:08 === ERROR: Could not find 'wxe_driver.so' in: /usr/local/Cellar/erlang/R16B03/lib/erlang/lib/wx-1.1.1/priv {ok,<0.42.0>} The debugger window still starts despite the error report. Why the error? Will it cause debugger problem down the road? Erlang runtime is installed by homebrew. Version number is R16B03 回答1: I find a solution: brew install wxmac It works with

Erlang debugger error: Could not find 'wxe_driver.so'

限于喜欢 提交于 2020-01-15 07:48:13
问题 I can see the following error report when I start up the debugger. 2> debugger:start(). =ERROR REPORT==== 23-Jan-2014::11:59:08 === ERROR: Could not find 'wxe_driver.so' in: /usr/local/Cellar/erlang/R16B03/lib/erlang/lib/wx-1.1.1/priv {ok,<0.42.0>} The debugger window still starts despite the error report. Why the error? Will it cause debugger problem down the road? Erlang runtime is installed by homebrew. Version number is R16B03 回答1: I find a solution: brew install wxmac It works with

安装升级Erlang/OTP的方法

戏子无情 提交于 2020-01-15 01:59:19
安装升级Erlang/OTP的方法 步骤:下载kerl,添加执行权限,构建,安装,激活。 详细步骤如下: 1、下载kerl script [root@localhost kerl]# curl -O https://raw.githubusercontent.com/yrashk/kerl/master/kerl 2、添加执行权限 [root@localhost kerl]# chmod a+x kerl 3、列出当前可用的erlang版本 [root@localhost kerl]# ./kerl list releases 4、构建指定的版本 [root@localhost kerl]# ./kerl build 21.1 5、install版本 [root@localhost kerl]# ./kerl install 21.1 6、激活版本 source /PATH(路径下)/activate 7、查看进程和状态 [root@localhost kerl]# ./kerl status [root@localhost kerl]# ./kerl active [root@localhost kerl]# ps aux|grep erlang 注: 如果升级erlang,查看可升级的版本:[root@localhost kerl]# ./kerl update

erlang processes and message passing architecture

本小妞迷上赌 提交于 2020-01-14 22:53:52
问题 The task I have in hand is to read the lines of large file, process them, and return ordered results. My algorithm is: start with master process that will evaluate the workload (written in the first line of the file) spawn worker processes: each worker will read part of the file using pread/3, process this part, and send results to master master receives all sub-results, sort, and return so basically no communication needed between workers. My questions: How to find the optimal balance