erlang

jInterface to create External Erlang Term

℡╲_俬逩灬. 提交于 2019-12-14 02:25:09
问题 How can I format the the following erlang term: { atom, "message" } In jInterface to an external format that I may call in an erlang shell erlang:binary_to_term( Binary ) Example: Note that since the tuple will be sent over the net, I finish by converting to byte[]. OtpErlangObject[] msg = new OtpErlangObject[2]; msg[0] = new OtpErlangAtom( "atom" ); msg[1] = new OtpErlangString( "message" ); OtpErlangTuple reply = new OtpErlangTuple(msg); OtpOutputStream stream = new OtpOutputStream(reply);

ETS creation return value

混江龙づ霸主 提交于 2019-12-14 01:27:24
问题 I'm using Elixir 1.6.3. I'm working with the Erlang :ets module in Elixir, and I'm a bit confused by the return value of the :ets.new/2 function. According to the doc's example, when calling :ets.new(:whatever, []) , I should be returned what appears to be an integral value: iex> table = :ets.new(:buckets_registry, [:set, :protected]) 8207 However, when I run the exact same code in iex , I get a reference: iex(1)> table = :ets.new(:buckets_registry, [:set, :protected]) #Reference<0.1885502827

Erlang: starting slave node

徘徊边缘 提交于 2019-12-14 01:00:29
问题 I'm trying to start erlang slave node on cluster and I receive "bash: erl: command not found" message. Though I have alias for erl. Here is what I actually do: [user@n001 ~]$ erl -rsh ssh -sname n001 Eshell V5.7.5 (abort with ^G) (n001@n001)1> slave:start_link("user@n002", n002, "-rsh ssh"). bash: erl: command not found {error,timeout} (n001@n001)2> Maybe, there is something wrong? Thanks. UPDATE: I've added erlang bin dir to my $PATH variable; I've set $ERLANG_ROOT_DIR variable; created

couchdb erlang reduce - aggregate object

橙三吉。 提交于 2019-12-13 18:12:04
问题 Say I have a map that emits the following objects {"basePoints": 2000, "bonusPoints": 1000} {"basePoints": 1000, "bonusPoints": 50} {"basePoints": 10000, "bonusPoints": 5000} How could I write a reduce in Erlang (not javascript) that would return an aggregate object like this: {"basePoints": 13000, "bonusPoints": 6050} (I would rather not have to write 2 separate views that emits each value separately if I can help it) Many Thanks! 回答1: You actually do not need special reduce, in this case

I cannot access to nitrogen/inets server from any machine but the localhost

自作多情 提交于 2019-12-13 17:59:57
问题 Thanks to many discussions in this forum, I found that I should be able to build the application I was planning to do for home usage based on Nitrogen. So I ran into Nitrogen tutorials, Demo and docs, and start to do some tests based on the self contained inets/nitrogen site. Everything was going well until I wanted to try to access my new website from another PC. Of course I had to tune my box first in order to route wan requests to lan... But after a day searching, reading and testing, I am

How does an Erlang process bind to a specific scheduler?

橙三吉。 提交于 2019-12-13 17:23:01
问题 How does an Erlang process bind to a specific scheduler? 回答1: Currently processes does not get bound to specific schedulers (though you can force it via undocumentet functions, not recommended). Scheduler threads may be bound to logical processors using cpu topology and binding types. The vm does use some of this information to enhance performance in its normal scheduling scheme. 回答2: Reading from an old mail from Kenneth Lundin: The Erlang VM without SMP support has 1 scheduler which runs in

How to connect to a registered Node (Erlang) and use it from Ejabberd

主宰稳场 提交于 2019-12-13 17:14:59
问题 I have a server application with a running node, awaits for rpc calls.... (n2@198.XXX.X.XX)> I have a node started on a different machine in which I have ejabberd running as well erl -name n2@198.XXX.X.XX -setcookie somecookie (n1@198.XXX.X.XX)> And then I have ejabberd server started with ejabberdctl live and I want to be able to ping n2 from n1 (n1@198.XXX.X.XX)>. I can see that n1 is registered and running with net_adm:names(). I tried to do do directly from code net_adm:ping(n2@198.XXX.X

Erlang Dialyzer integer ranges

天大地大妈咪最大 提交于 2019-12-13 16:05:01
问题 -module(test). -export([f/0, g/0]). -spec f() -> RESULT when RESULT :: 0..12 . -spec g() -> RESULT when RESULT :: 0..13 . f () -> 100 . g () -> 100 . Running dialyzer (and typer) only the function f is caught. dialyzer test.erl Checking whether the PLT /Users/ben/.dialyzer_plt is up-to-date... yes Proceeding with analysis... test.erl:4: Invalid type specification for function test:f/0. The success typing is () -> 100 done in 0m0.53s done (warnings were emitted) the same with typer typer test

Erlang string from list

萝らか妹 提交于 2019-12-13 15:28:23
问题 I have erlang list symbols: [104, 105, 106, 107 ...] How can i got string from this list: "hijk..." ? Thank you. 回答1: Strings as a datatype do not exist in Erlang. Stings are simply lists of characters. [104, 105, 106, 107] and "hijk" are perfectly equivalent. In fact, if you type the original list in the shell you get back the "string": 1> [104, 105, 106, 107]. "hijk" 来源: https://stackoverflow.com/questions/10276982/erlang-string-from-list

List to list of tuples convertion

混江龙づ霸主 提交于 2019-12-13 15:26:05
问题 I want to convert [z,z,a,z,z,a,a,z] to [{z,2},{a,1},{z,2},{a,2},{z,1}] . How can I do it? So, I need to accumulate previous value, counter of it and list of tuples. I've create record -record(acc, {previous, counter, tuples}). Redefined listToTuples([]) -> []; listToTuples([H | Tail]) -> Acc = #acc{previous=H, counter=1}, listToTuples([Tail], Acc). But then I have some trouble listToTuples([H | Tail], Acc) -> case H == Acc#acc.previous of true -> false -> end. 回答1: if you build up your answer