erlang

Authentication failed (rejected by the remote node), please check the Erlang cookie

梦想的初衷 提交于 2019-12-31 12:58:25
问题 I installed erlang and rabbitmq in the way mentioned in the official documentation. But then, when I do this C:\Program Files\RabbitMQ Server\rabbitmq_server-3.7.0\sbin>rabbitmqctl add_user XXXXXX YYYYYYY it gives me the following error... Error: unable to perform an operation on node 'rabbit@C001741998'. Please see diagnostics information and suggestions below. Most common reasons for this are: Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)

How to debug Erlang code?

拜拜、爱过 提交于 2019-12-31 08:28:10
问题 I have some Ruby and Java background and I'm accustomed to having exact numbers of lines in the error logs. So, if there is an error in the compiled code, I will see the number of line which caused the exception in the console output. Like in this Ruby example: my_ruby_code.rb:13:in `/': divided by 0 (ZeroDivisionError) from my_ruby_code.rb:13 It's simple and fast - I just go to the line number 13 and fix the error. On the contrary, Erlang just says something like: ** exception error: no

Adding to an existing value in Erlang

末鹿安然 提交于 2019-12-31 04:07:23
问题 I am attempting to create a function that stores a number into a record and then adds value X to that number every time the function runs. Value: 5 Run Function (Add One): 1 Value should be: 6 Run Function (Add One): 1 value should be 7 I tried to use a record: -record(adder,{value :: integer()}). ---function Number = random:uniform(6), L=#added{value = Number + #added.value}. This does not work as it resets the value every time. Any suggestions? 回答1: Take a look at this code: -module(test).

About the | operator in erlang.

放肆的年华 提交于 2019-12-31 01:58:04
问题 We can make a nested list in erlang by writing something like this: NL = [[2,3], [1]]. [[2,3],[1]] But assume we wrote it like this instead: OL = [[2,3]|1]. [[2,3]|1] Is OL still a list? Can someone please elaborate more what OL is? 回答1: This is called an improper list and should typically not be used. I think most library functions expects proper lists (e.g. length([1|2]) throws bad argument exception). Pattern matching with improper lists works though. For some use cases, see Practical use

Java to Erlang messages

北城以北 提交于 2019-12-30 08:45:08
问题 I'm making a application in Erlang, with a GUI in Java. I've managed to establish a connection between the to languages, but now i need to (i guess) send a message from Java to Erlang, every time I e.g press a button. Is that the right way to go? How would such a message look? I've found a few good sites about this form of integration, but I feel like im not getting everything. http://www.trapexit.org/How_to_communicate_java_and_erlang 回答1: If jinterface is too complicated you might just use

Elixir - problems with https URLs

只谈情不闲聊 提交于 2019-12-30 08:29:25
问题 I'm new to Elixir and Erlang and having some issues with accessing https URLs. I've tried the Elixir-specific HTTPotion and Erlang's :inets module. So from the iex console (Interactive Elixir): With HTTPotion: HTTPotion.start HTTPotion.get("https://api.github.com") With :inets: :inets.start :ssl.start :httpc.request('https://api.github.com') In both cases I get a giant stacktrace that essential says there is a bad match somewhere and that a state machine is terminating. I don't get this when

Profiler/Analyzer for Erlang?

别等时光非礼了梦想. 提交于 2019-12-30 07:57:48
问题 Are there any good code profilers/analyzers for Erlang? I need something that can build a Call graph for my code. 回答1: For static code analysis you have XREF and DIALYZER, for profiling you can use cprof, fprof or eprof, you can get good reference here... 回答2: The 'fprof' module includes profiling features. From the fprof module documentation: fprof:apply(foo, create_file_slow, [junk, 1024]). fprof:profile(). fprof:analyse(). fprof:apply (or trace ) runs the function, profile converts the

Profiler/Analyzer for Erlang?

牧云@^-^@ 提交于 2019-12-30 07:57:10
问题 Are there any good code profilers/analyzers for Erlang? I need something that can build a Call graph for my code. 回答1: For static code analysis you have XREF and DIALYZER, for profiling you can use cprof, fprof or eprof, you can get good reference here... 回答2: The 'fprof' module includes profiling features. From the fprof module documentation: fprof:apply(foo, create_file_slow, [junk, 1024]). fprof:profile(). fprof:analyse(). fprof:apply (or trace ) runs the function, profile converts the

how to read the contents of a file In Erlang?

霸气de小男生 提交于 2019-12-30 04:00:08
问题 I know you can do something like this: readlines(FileName) -> {ok, Device} = file:open(FileName, [read]), get_all_lines(Device, []). get_all_lines(Device, Accum) -> case io:get_line(Device, "") of eof -> file:close(Device), Accum; Line -> get_all_lines(Device, Accum ++ [Line]) end. : Is there a one liner BIF that can do this too? 回答1: file:read_file/1 is what you are looking for. Just for teaching purpose, Accum ++ [Line] is bad practice. Problem is that left argument of ++ is copied and

What is the difference between == and =:= in Erlang when used with terms in general?

蓝咒 提交于 2019-12-30 03:44:06
问题 Apart from the fact that =:= prevents unwanted integer casts: 1> 1=:=1.0. false What is the advantage of using =:= with terms in general? Better performance? 回答1: The biggest advantage of =:= is it returns true only for same terms in the same way as pattern matching. So you can be sure they are same. 1 and 1 are same terms and 1 with 1.0 are not. That's it. If you write function like foo(A, B) when A =:= B -> A. and bar(A, B) when A =:= B -> B. they will behave same. If you use == it will not