erl

Erlang case statement

为君一笑 提交于 2019-12-24 04:22:14
问题 I have the following Erlang code and it is giving the warning as follows, when i try to compile it, but that make sense. function need two arguments, but i need to patten match "everything else" rather x, y or z. -module(crop). -export([fall_velocity/2]). fall_velocity(P, D) when D >= 0 -> case P of x -> math:sqrt(2 * 9.8 * D); y -> math:sqrt(2 * 1.6 * D); z -> math:sqrt(2 * 3.71 * D); (_)-> io:format("no match:~p~n") end. crop.erl:9: Warning: wrong number of arguments in format call. I was

Why use OTP with erlang?

浪尽此生 提交于 2019-12-22 04:26:05
问题 As the question said: What benefits brings using the OTP design principles when developing with erlang? (I am developing a server which will just receive commands and send responses) 回答1: OTP is a battle-hardened set of design elements and idioms used in the creation of, as Jonas said, fault-tolerant systems among other things (like flexibility, live updates, etc.). In brief you want to use it for these environments, or environments that may grow into these, because a lot of the blood, sweat

Getting two erl shells to talk on OS X

南笙酒味 提交于 2019-12-19 18:24:17
问题 I want to be able to have two Erlang shells to talk. I'm running on OS X. I tried the tut17 example here. I've also tried: $ erl -sname foo and then in a new Terminal: $ erl -sname bar (bar@elife)1> net_adm:ping(foo@elife). pang Any ideas? 回答1: It's kind of broken on the mac. By default, the mac can't resolve its own shortname. Your host's name is really probably "elife.local". If you start erl with -name FQDN, then the pings will work. ie: you would start it with $ erl -name foo@elife.local

rabbitmq-server installation CentOS - Erlang Error

一个人想着一个人 提交于 2019-12-18 18:23:38
问题 I have centos 6 and trying to install rabbitmq 3.5.3 using rpm. ( do not have option for yum ) its throwing me below eror. [root@osboxes CentOS]# rpm -Uvh rabbitmq-server-3.5.3-1.noarch.rpm warning: rabbitmq-server-3.5.3-1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 056e8e56: NOKEY error: Failed dependencies: erlang >= R13B-03 is needed by rabbitmq-server-3.5.3-1.noarch But I have already installed erlang [root@osboxes CentOS]# which erl /usr/bin/erl [root@osboxes CentOS]# [root@osboxes

Erlang VM -s argument misbehaving

陌路散爱 提交于 2019-12-13 05:15:38
问题 When I start up a function within the erl shell, it works fine. When I try to invoke the same function with erl ... -s module function, it fails. The line of code that eventually fails is: start(Port) -> mochiweb_http:start([{port, Port}, {loop, fun dispatch_requests/1}]). I'm positive that Port is set correctly. My error message is: =CRASH REPORT==== 17-Jan-2010::00:21:09 === crasher: initial call: mochiweb_socket_server:acceptor_loop/1 pid: <0.65.0> registered_name: [] exception exit:

Sending message Pid Erlang

天涯浪子 提交于 2019-12-12 16:55:58
问题 I would like to know, how can i send a message to process with erlang. I did start a process and the output shows me that the pid is <0.39.0>. My problem is how can i send a message to this process (<0.39.0>) manually. Anyhelp would be appreciated 回答1: While list_to_pid/1 can indeed be used to construct a PID and use it to send messages its usage is discouraged: This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in application programs. A

Erlang: check duplicate inserted elements

烈酒焚心 提交于 2019-12-11 11:21:38
问题 I want to know if inserted elements are duplicated. Here is simple example for what I'm looking for : In first run should return false. check_duplicate("user", "hi"). But in second run should return true. check_duplicate("user", "hi"). 回答1: One of best features of functional programming is pure functions. There are even functional languages like Haskell where you can't write an impure function. A pure function always returns the same value for the same argument. An impure function has side

Elixir io_lib call to erlang

拥有回忆 提交于 2019-12-11 05:05:15
问题 io_lib:fread("~d/~d/~d", "2013/03/03"). Above code works in erlang so ideally in elixir below code should work :io_lib.fread("~d/~d/~d", "2013/03/03") but it generates error " no function clause matching " After inspecting found that elixir makes call to module like :io_lib_fread.fread("~d/~d/~d", "2013/03/03", 0, []) 回答1: A double quote in erlang "char list" translates to single quotes in Elixir 'char list' . 来源: https://stackoverflow.com/questions/18756293/elixir-io-lib-call-to-erlang

RabbitMQ: erl.exe taking high CPU usages

情到浓时终转凉″ 提交于 2019-12-08 15:49:07
问题 I have implemented rabbitmq in my application and it's running on windows server 2008 server, the problem is that erl.exe taking high CPU usages like sometime it reaches 40-45% CPU usages, even in the ideal case (when not processing any queue) it takes at least 4-15% CPU usages. What could be the reason for taking high CPU usages? Is there any setting or any other thing that I need to do. 回答1: You say that even when not processing a queue it is still at 4-15%, but is your application running?

Why use OTP with erlang?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 03:24:00
As the question said: What benefits brings using the OTP design principles when developing with erlang? (I am developing a server which will just receive commands and send responses) OTP is a battle-hardened set of design elements and idioms used in the creation of, as Jonas said, fault-tolerant systems among other things (like flexibility, live updates, etc.). In brief you want to use it for these environments, or environments that may grow into these, because a lot of the blood, sweat and tears of creating reliable, stable systems in Erlang is baked into the OTP behaviours and architecture.