erlang

problems installing Erlang/OTP

天大地大妈咪最大 提交于 2019-12-12 10:58:19
问题 I'm trying to install Erlang/OTP following the documentation at http://www.erlang.org/doc/installation_guide/INSTALL.html. I'm having problems building the Erlang/OTP release. When I run make , I get: Makefile:247: /home/otp_src_17.0/make/i686-pc-linux-gnu/otp_ded.mk: No such file or directory make: *** No rule to make target `/home/amiro/otp_src_17.0/make/i686-pc-linux-gnu/otp_ded.mk'. Stop. Has anyone here encountered this kind of problem? 回答1: That error occurred while building the Erlang

How is the detection of terminated nodes in Erlang working? How is net_ticktime influencing the control of node liveness in Erlang?

亡梦爱人 提交于 2019-12-12 10:57:02
问题 I set net_ticktime value to 600 seconds. net_kernel:set_net_ticktime(600) In Erlang documentation for net_ticktime = TickTime: Specifies the net_kernel tick time. TickTime is given in seconds. Once every TickTime/4 second, all connected nodes are ticked (if anything else has been written to a node) and if nothing has been received from another node within the last four (4) tick times that node is considered to be down. This ensures that nodes which are not responding, for reasons such as

How to use mochijson to encode data structure in erlang?

梦想与她 提交于 2019-12-12 10:44:52
问题 I am using mochiweb and I don't know how to use its json encoder to deal with complex data structure. What's the differences between mochijson and mochijson2? Is there any good example? I always get the following errors: 46> T6={struct,[{hello,"asdf"},{from,"1"},{to,{a,"aa"}}]}. {struct,[{hello,"asdf"},{from,"1"},{to,{a,"aa"}}]} 47> mochijson2:encode(T6). ** exception exit: {json_encode,{bad_term,{a,"aa"}}} in function mochijson2:json_encode/2 in call from mochijson2:'-json_encode_proplist/2

Erlang: “prepending” an element to a tuple

本秂侑毒 提交于 2019-12-12 10:40:26
问题 Is it possible to write a faster equivalent to this function? prepend(X, Tuple) -> list_to_tuple([X | tuple_to_list(Tuple)]). 回答1: As prepending an element is the same as inserting it at position 1, you can use the built-in function erlang:insert_element/3: > erlang:insert_element(1, {a, b}, z). {z,a,b} This function was added in Erlang/OTP R16A. 回答2: It looks to me like that sort of thing is discouraged. If you want a list, use one. Getting Started with Erlang: Tuples have a fixed number of

How to implement FCM push notification in ejabberd XMPP server

好久不见. 提交于 2019-12-12 10:40:05
问题 I have implemented apns notification using ejabberd, for apns we need to use mod_apns.erl file only. I want to implement push notification in android device using FCM as GCM is deprecated. previously mod_gcm.erl file available for GCM push notification. Please help me to integrate FCM push notification in ejabberd . Installed Ejabberd Version: 16.09 来源: https://stackoverflow.com/questions/49608100/how-to-implement-fcm-push-notification-in-ejabberd-xmpp-server

Is there a way to do lookups on default record values?

左心房为你撑大大i 提交于 2019-12-12 10:13:17
问题 Given a record -record(something, {id :: integer(), name :: string(), email = undefined :: string() | undefined}). Is there a way to get the default values for the fields, in this example getting the fact that #something.email defaults to undefined? 回答1: Records are syntactic sugar in Erlang , expanded by the compiler. The following solution, suggested by @Dmitry, works, but the compiler will not optimize it away unless you pass +inline, since the trick here is to really create a record: g()

How can i parse the standard input with the erlang api?

二次信任 提交于 2019-12-12 10:08:54
问题 I'm developing a game in Erlang, and now i need to read the standard input. I tried the following calls: io:fread() io:read() The problem is that i can't read a whole string, when it contains white spaces. So i have the following questions: How can i read the string typed from the user when he press the enter key? (remember that the string contains white spaces) How can i convert a string like "56" in the number 56? 回答1: Read line You can use io:get_line/1 to get string terminated by line

Riak database fails after a short period

坚强是说给别人听的谎言 提交于 2019-12-12 09:58:22
问题 I crerated a simple erlang application which periodically collects required data and puts it in a riak database. As I start my application it runs smoothly.. but after a period of time it stucks as PUT requests to riak database becomes too slow.. It is logs from my app: 2013-06-26 12:44:09.090 [info] <0.60.0> data processed in [16476 ms] 2013-06-26 12:45:51.472 [info] <0.60.0> data processed in [18793 ms] ... 2013-06-26 12:57:28.138 [info] <0.60.0> data processed in [15135 ms] 2013-06-26 13

Extracting C functions signatures for Erlang

只愿长相守 提交于 2019-12-12 09:55:10
问题 I was wondering what the most suitable tool is for extracting c (and eventually c++) function names, arguments and their types from source code. I would like to use a tool that can be automated as much as possible. I want to extract the signature types then have the output read by another program written in Erlang. My goal is to use this information to construct the equivalent of the C types/signatures in Erlang (using ei). I would like this process to work for any C file so I can't use any

How to convert infix to postfix in erlang?

我只是一个虾纸丫 提交于 2019-12-12 09:39:19
问题 I just came across this post,it's quite elegant. But it's not taking into account the priority of different operators. e.g. * has higher priority than + . So 1+2*(3+2) should be converted to 1 2 3 2 + * + How to do it in erlang taking the priority issue into account? 回答1: Here is a way to do it which abuses the built-in parser for Erlang terms. You could write your own parser via yecc or recursive descent, but for the simplicity, I'll stick with the Erlang-parser. -module(foo). -compile