erlang

rabbitmq-erlang-client, using rebar friendly pkg, works on dev env fails on rebar release

好久不见. 提交于 2019-12-24 00:33:40
问题 I am successfully using the rebar-friendly package of rabbitmq-erlang-client for a simple Hello World rebarized and OTP "compliant" app and things work fine on the dev environment. I am able to fire up an erl console and do my application:start(helloworld). and connect to the broker, open up a channel and communicate to queues. However, then I proceed to do rebar generate and it builds up the release just fine, but when I try to fire up from the self contained release package then things

What is the difference between \“ and ”" in Erlang

萝らか妹 提交于 2019-12-24 00:14:50
问题 In Erlang, \" is an escape character that means double quote. My question is, what is the difference between "\"test\"" and ""test"" ? The reason I ask is because, I'm trying to handle a list_to_atom error: > list_to_atom("\"test\""). '"test"' > list_to_atom(""test""). * 1: syntax error before: test 回答1: "" is a string/list of length 0 \" is just an escaped double-quote when used in the context of a string. If you wanted to have a string that consists of just a double-quote (ie \" ), then you

can't add multicast group

有些话、适合烂在心里 提交于 2019-12-23 23:05:16
问题 Trying to add multicast group for ipv6, but it returns error. don't understand the problem. with ipv4 it works fine (test_client@127.0.0.1)1> {ok, S} = gen_udp:open(3333, [binary, {active, false}, {ip, {65342,0,0,0,0,0,34048,9029}}, inet6, {multicast_loop, false}]). {ok,#Port<0.1587>} (test_client@127.0.0.1)4> inet:setopts(S, [{add_membership, {{65342,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}}}]). {error,einval} unfortunately this topic in erlang docs is badly documented also have tried with

Is “new” in Erlang part of the official standard and should we use it?

£可爱£侵袭症+ 提交于 2019-12-23 20:28:57
问题 I ask this question as I have noticed that alot of OpenSource Erlang projects use "new" to pass parameters to Erlang modules, yet I hear at the same time that "new" is not part of the official language and may not be supported if it contains bugs. Before I use it in my own project I would like to clarify this issue. Update: I have since asked on the official Erlang mailing list for an answer: http://www.erlang.org/cgi-bin/ezmlm-cgi?4:mss:49535:201002:aicfhmngkhodmclhlnak 回答1: There is no

How to perform a case-insensitive file search in Erlang/Elixir

老子叫甜甜 提交于 2019-12-23 20:11:29
问题 Elixir provides Path.wildcard , which uses the Erlang :filelib.wildcard function internally. Matching is case-sensitive, for example, "a" does not match "A". (http://erlang.org/doc/man/filelib.html#wildcard-1) Please is there a case-insensitive alternative? 回答1: There's no built in option to do this, but since the wildcard syntax supports character alternations similar to regex, you can replace every letter with an alternation of its lower and upper case versions, e.g. f0o -> [fF]0[oO] , and

How to perform a case-insensitive file search in Erlang/Elixir

自闭症网瘾萝莉.ら 提交于 2019-12-23 19:50:30
问题 Elixir provides Path.wildcard , which uses the Erlang :filelib.wildcard function internally. Matching is case-sensitive, for example, "a" does not match "A". (http://erlang.org/doc/man/filelib.html#wildcard-1) Please is there a case-insensitive alternative? 回答1: There's no built in option to do this, but since the wildcard syntax supports character alternations similar to regex, you can replace every letter with an alternation of its lower and upper case versions, e.g. f0o -> [fF]0[oO] , and

Erlang: include module and call functions

☆樱花仙子☆ 提交于 2019-12-23 19:45:48
问题 I am going through Erlang code. tes_lib:check_operational(Config) The above code is present in a module called Sample.erl . I am new to this language. My question is that I cannot see any include statement for the module tes_lib in Sample.erl . So, how come Sample.erl is able to call the function check_operational using tes_lib module? I thought that it should be like Java, where we first import the class and then call the function. 回答1: In Erlang, you don't need to "import" modules in order

How to pass a digraph to a different process and node?

…衆ロ難τιáo~ 提交于 2019-12-23 18:13:42
问题 I have created a digraph term on process A and I want to pass this digraph to a process on another node. Whenever I use this digraph on the other process I am getting errors such as: ** {badarg, [{ets,insert,[598105,{"EPqzYxiM9UV0pplPTRg8vX28h",[]}],[]}, {digraph,do_add_vertex,2,[{file,"digraph.erl"},{line,377}]}, Becasuse a digraph is based on ETS, it appears that this is quite more complicated, making a digraph pretty much standalone on the process it was created. I have found this entry

Erlang get_tcp:recv data length

允我心安 提交于 2019-12-23 17:48:23
问题 I user gen_tcp:recv(Socket, 0). for data receiveng, but i can receive only 1418 bytes for 1 time. How can I receive how much data was sent? 回答1: in gen_tcp:recv(Socket, 0) you are asking the kernel: "Give me all data there is available right now in the receive buffer". The kernel is also free to give you less however. Even for a rather fast link, you will probably hit slow start on the TCP connection so in the beginning you will not get much data. The solution is to do your own buffering. You

Avoid NZEC error in Erlang in SPOJ

℡╲_俬逩灬. 提交于 2019-12-23 16:03:50
问题 I've written code in Erlang, and I get the correct answer on my machine. But when I submit it on SPOJ it gives an NZEC (non zero exit code) error. I have used built-in functions like halt() and init:stop() , and their specification clearly says that they are used to avoid non-zero exit code error. But still I get the same error. How can I solve this problem? EDIT The code as required by a comment: -module(factorial). -export([main/0]). main() -> {ok, [No_of_cases]} = io:fread("", "~d"), loop