erlang

Where are the Erlang libraries?

Does Erlang have libraries? Like math or stdio, from the C language. Where can they be found? ...

How to handle mnesia schemas the standard way?

Suppose i have an application A which depends on mnesia with disk-enabled schema being present. What i'd like to do is ensure that mnesia is running and allowing disc_copiestables from within A. I'm also considering the case where multiple applications need to access mnesia. What would be the most portable (and standard) way to achie...

Erlang - Standard location of mnesia database

Hi, Is there a standard place to put the mnesia database within erlang? At the moment I am putting it in the priv directory. ...

List of PID's in Erlang

Long story short I am trying to replicate the Sleeping barber problem in Erlang. In my solution I decided that for all the processes that are waiting I would put them into a list. Then, once it was that processes turn, I would take that PID off of the list. Unfortunately when I call length(myListOfPids). it fails, as an example: ...

starting remote erlang nodes

hi guys, I want to write a master-slave application in Erlang. I am thinking at the following things I need from the architecture: the slaves shouldn't die when the master dies, but rather try to reconnect to it while the master is down the master should automatically start the remote nodes if they don't connect automatically or they a...

Are Erlang/OTP messages reliable? Can messages be duplicated?

Long version: I'm new to erlang, and considering using it for a scalable architecture. I've found many proponents of the platform touting its reliability and fault tolerance. However, I'm struggling to understand exactly how fault-tolerance is achieved in this system where messages are queued in transient memory. I understand that a ...

Prolog term to Erlang

Let's say you have this prolog term "city(London, England)". ie London is a city in England. How do you represent that in Erlang, pattern matching? ...

calculate the latency between Erlang and C program

I am using Erlang for driving robot using wireless serial communication. I want to use the robot in safety critical systems so I need to calculate the latency between Erlang and C program. Can anybody tell me how to calculate latency between 2 program communicating with each other? Thanks in advance.... : ...

printing output of lists:keysearch erlang

Hi, I am not able to print the return output of the following lists:keysearch function. case lists:keysearch(Query,1,Data) of {value,Answer} -> io:format("~p",Answer); false -> io:format("not found ~n") end, I know Answer is my tuple that i should print out.Can anyone tell me what mistake i am doing ? thanks in advance...

A good OpenID implementation in Erlang?

Hi, I'm looking for a good (Or at least working) implementation of OpenID in erlang. I've looked at several different solutions, but non of them are working 100%. ...

How to concat lists in erlang without creating nested lists?

I'm trying to be a good erlanger and avoid "++". I need to add a tuple to the end of a list without creating a nested list (and hopefully without having to build it backwards and reverse it). Given tuple T and lists L0 and L1: When I use [T|L0] I get [tuple,list0]. But when I use [L0|T], I get nested list [[list0]|tuple]. Similarly, [L...

What is the proper way to create an apache-style log file using Erlang?

I think there is a specific module for this but can no longer figure out where I saw it ... ...

Why is Erlang said to be more suited for server side programming in webgames than Java and C++?

I don't really understand, how can Erlang be more efficient than C++? ...

Erlang - Anonymouos Function

If i call the test(), it doesnt work. Can someone explain this ?. -module(anony). -export([test/0, test1/0]). test1() -> "hello". test() -> C = fun(F) -> Val = F(), io:format("~p ", [Val]) end, lists:foreach(debug, [test1]). ...

Erlang simple server problem.

Hello, As I learn Erlang, I'm trying to solve ex. 4.1 ("An Echo server") from "Erlang Programming" book (by O'Reilly) and I have a problem. My code looks like that: -module(echo). -export([start/0, print/1, stop/0, loop/0]). start() -> register(echo, spawn(?MODULE, loop, [])), io:format("Server is ready.~n"). loop() -> rec...

Hierarchical state machine implementation in Erlang

Hi! I am planning a turn based game (a sort of board game), and the backend will probably be done in Erlang. The game logic part seems to be a fit for a hierarchical state machine, but I'm not sure about how to implement that in Erlang. Maybe I can spawn a separate process with each child fsm, not sure if this would work. Another opti...

Design pattern? Function iterating through a list in search of the first {success} result

I've got a coding problem in Erlang that is probably a common design pattern, but I can't find any info on how to resolve it. I've got a list L. I want to apply a function f to every element in L, and have it run across all elements in L concurrently. Each call to f(Element) will either succeed or fail; in the majority of cases it wil...

JSON-encode a list using mochiweb

I need to JSON-encode a list using mochiweb. How do I get the following: List = ["This is message 1.", "This is message 2.", "This is the last message"] mochijson2:encode({struct,[{messages,list_to_binary(List)}] to produce this bit of JSON: {"messages":"["This is message 1.","This is message 2.","This is the last message"]} ...

"average length of the sequences in a fasta file": Can you improve this Erlang code ?

I'm trying to get the mean length of fasta sequences using Erlang. A fasta file looks like this >title1 ATGACTAGCTAGCAGCGATCGACCGTCGTACGC ATCGATCGCATCGATGCTACGATCGATCATATA ATGACTAGCTAGCAGCGATCGACCGTCGTACGC ATCGATCGCATCGATGCTACGATCTCGTACGC >title2 ATCGATCGCATCGATGCTACGATCTCGTACGC ATGACTAGCTAGCAGCGATCGACCGTCGTACGC ATCGATCGCATCGATGCTACGATC...

Avoid NZEC error in erlang in SPOJ

I ve written code in erlang and i am getting correct answer in my machine. But when i am submitting it in spoj.pl it is giving nzec(non zero exit code) error. I have used inbuilt 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 am geting same error...