erlang

Binary operations on Erlang binaries?

What's best way to do the following? Binary -> list -> binary seems unnecessary. binary_and(A, B) -> A2 = binary_to_list(A), B2 = binary_to_list(B), list_to_binary([U band V || {U, V} <- lists:zip(A2, B2)]). ...

Erlang file truncation

I'm trying to write a basic Erlang program that reads in a file in one process and writes the file in another process. I'm finding that sometimes the output file gets truncated. For instance I wrote eunit test. If I run the single test drive_test:write_file_test() the output is correctly written. But running drive_test:test() truncat...

Erlang list comprehension with two lists in sequence?

Is it possible to use list comprehension on two lists, item by item, in sequence? Given A = [1,2,3], B = [4,5,6], get some C = [f(1, 4), f(2, 5), f(3, 6)]. In other words, a more direct/efficient way to do [f(U, V) || {U, V} = lists:zip(A, B)]. Similar question goes to binaries, if given A = <<1,2,3>> and B = <<4,5,6>>. This would be ve...

How do I authenticate with couchdb using couchbeam?

I'm trying to create a database in couchdb, which has an admin user/password set, using couchbeam. I've set my credentials in couchdb's local.ini file and restarted. My code to create a db is: couchbeam:start(), Params = #couchdb_params{username="test" ,password="pass"}, Connection = couchbeam_server:start_connection_link(Params), Db = ...

Erlang: getting the "registered name" associated with a `pid`

Is there a direct way to retrieve the registered name associated with a pid() ? Or do I have to go through the registered() names and do a whereis() on each element of the list to find it? ...

Kohana event system in Erlang?

I want to implant a framework in Erlang that is similar to Kohana event system. Anyone know how to do that or have any idea? I really like how Kohana is structured. EDIT The Kohana event system have been documented here : http://docs.kohanaphp.com/general/events . If I understand it correctly, I can replicate Kohana in Erlang like this...

What other systems beside Erlang are based on "Green Processes"?

I was reading this informative page on Green Thread (Wikipedia) and I wonder: what other programming systems rely on "green processes" beside Erlang? Edit: " Green Thread != Green Process " Green Process based Erlang Inferno Green Thread based Go Native Process based C, C++ Updated: Nobody answered the question directly and...

Erlang and Antlr

Is it possible to write an Antlr code generation target for Erlang? ...

Erlang Scripting Language Interpreter

Does anyone know of an implementation of a scripting language interpreter (something appropriate for a game) in Erlang? Something like Javascript or Lua would be great. ...

How to filter messages in Ejabberd

I have Ejabberd up and running with test users, and its working fine. I want to write a module that can intercept messages and modify them, as follows : intercept "messages" send them to a php file get the result from the same php file (immediate) Modify the message stanza and send it down the wire to the recipient The ejabberd docum...

[Erlang] Spawn remote process w/o common file system

([email protected])8> spawn([email protected], tut, test, [hello, 5]). I want to spawn a process on bar.del.com which has no file system access to foo.hyd.com (from where I am spawning the process), running subroutine "test" of module "tut". Is there a way to do so, w/o providing the [email protected] with the compiled "tut" module fi...

[Erlang] Terms in the node startup message.

Possible Duplicate: What do the Erlang emulator info statements mean? [email protected]:/u/baskin> erl -name nodeA Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] Hello, What do these terms stand for? [source] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll...

What's the difference between "green threads" and Erlang's processes?

After reading about Erlang's lighweight processes I was pretty much sure that they were "green threads". Until I read that there are differences between green threads and Erlang's processes. But I don't get it. What are the actual differences? ...

ejabberd supervisor module

I need to keep a gen_mod process running as it loops every minute and does some cleanup. However once every few days it will crash and I'll have to manually start it back up again. I could use a basic example of implementing a supervisor into ejabberd_sup so it can keep going. I am struggling to understand the examples that use gen_se...

Using trace and dbg in Erlang

I am trying to start using erlang:trace/3 and the dbg module to trace the behaviour of a live production system without taking the server down. The documentation is opaque (to put it mildly) and there don't appear to be any useful tutorials online. What I spent all day trying to do was capture what was happening in a particular functio...

Erlang C node related question

In the tutorial provided at: http://www.erlang.org/doc/tutorial/cnode.html There is the following example: /* cnode_s.c */ #include #include #include #include #include "erl_interface.h" #include "ei.h" #define BUFSIZE 1000 int main(int argc, char **argv) { int port; /* Listen port number */ int l...

Why does this erlang code eat so much memory?

I'm going through Cesarini and Thompson's "Erlang Programming" (O'Reilly) and I made a solution to 4-2 but after playing around with it there are two problems: Every time I run go/3, "werl.exe" in windows chews up X amount of RAM. Every subsequent call takes up the same amount and it's never reclaimed. If I run go(Message,10000,10) it ...

Should I be pattern matching every return value?

When I'm programming in Erlang should I be validating all return values from function calls for success via pattern matching even if i don't intend to use the return value? Most Erlang APIs I've seen so far don't throw exceptions on error (but return something like {error, Error}) so I must need to validate the return value yes? Any exce...

implement Comet with erlang and use it for PHP application

I'm building a PHP web application and I've reached a point that I need to build a Comet server because I need to update my users' whenever a new data is available (pretty much like FB). I've spent so much time searching the web and I've come to a conclusion that the best way to build Comet server is to build it with erlang. Also I've fo...

Erlang: What is most-wrong with this trie implementation?

Over the holidays, my family loves to play Boggle. Problem is, I'm terrible at Boggle. So I did what any good programmer would do: wrote a program to play for me. At the core of the algorithm is a simple prefix trie, where each node is a dict of references to the next letters. This is the trie:add implementation: add([], Trie) -> ...