erlang

Erlang erl_call causes gen_server module to quit

I have a genserver module which I need to start as a server running in the background. During development, I used a standard erl terminal to start it as $erl Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.2 (abort with ^G) 1> myserver:start_link(). <ok, some_pid> Everyth...

Markdown And Escaping Javascript Line Breaks

I am writing a markdown compiler in Erlang for server-side use. Because it will need to work with clients I have decided to adopt the client side library (showdown.js) as the specification and then test my code for compatibility with that. In the first couple of iterations I built up 260-odd unit tests which checked that my programme pr...

csv parser in erlang

for my application i have to parse CSV file using Erlang.following is the code which will parse CSV using Erlang:- parse_file(Fn) -> {ok, Data} = file:read_file(Fn), parse(binary_to_list(Data)). parse(Data) -> lists:reverse(parse(Data, [])). parse([], Acc) -> Acc; parse(Data, Acc) -> {Line, Tail} = parse_line(Data), parse(Tail, [Line|...

Erlang: Is there a way to pattern match a record in a receive clause?

I want to do a selective receive where a record property needs to be matched, but whatever syntax I try, I get an "illegal pattern" message. loop(State) -> receive {response, State#s.reference} -> do_something() end. Is this not possible? ...

String delimiting in Erlang

Is there an equivalent to Perl's """ in Erlang? I'd like to be able to define a pretty long string full of double-quotes without escaping every single one. Is that possible? Feel free to let me know if I'm Doing It Wrong. Thanks! ...

right rotate a List in Erlang

Hi, I am getting myself familiar to Sequential Erlang (and the functional programming thinking) now. So I want to implement the following two functionality without the help of BIF. One is left_rotate (which I have come up with the solution) and the other is right_rotate (which I am asking here) -export(leftrotate/1, rightrotate/1). %%(1...

Advice on Learning "How to Think Functional"?

As a newbie in functional languages (I started touching Erlang a couple of weeks ago -- the first functional language I could get my hands on). I started to writing some small algorithms (such as left_rotate_list, bubble_sort, merge_sort etc.). I found myself often getting lost in decisions such as "should I use a helper List for interm...

how to use erlang lists:map function

The following is a erlang function. I don't understand how lists:map function is used here. Could someone please explain? % perform M runs with N calls to F in each run. % For each of the M runs, determine the average time per call. % Return, the average and standard deviation of these M results. time_it(F, N, M) -> G = fun() -> ...

How do you debug functions from includes in Erlang?

The implementation of ScrumJet on GitHub (as of this writing) shares essentially identical functions between the storage modules for tasks, categories and boards. This was achieved by moving the identical code which makes heavy use of the ?MODULE macro into scrumjet_datastore.hrl. Each of scrumjet_task.erl, scrumjet_category.erl and sc...

mochijson2 or mochijson

Hi guys. I'm encoding some data using mochijson2. But I found that it behaves strange on strings as lists. Example: mochijson2:encode("foo"). [91,"102",44,"111",44,"111",93] Where "102", "111", "111" are $f, $o, $o encoded as strings 44 are commas and 91 and 93 are square brakets. Of course if I output this somewhere I'll ...

Erlang emacs mode - setting outdir

Hello, Does anyone know how to configure Erlang emacs mode so that compiling a buffer [C-c C-k] writes the beam file to the ebin directory rather than the current directory ? Thanks! ...

Mochiweb mnesia requests

I'm trying to link Mochiweb with my ejabberd mnesia db and am unable to do any mnesia transactions in my controllers. I test my controllers without the mnesia transactions and they work fine. I am using application:start(mnesia) inside the start function. On the browser, I see "Internal server error" and on Mochiweb's log I see, "=ERR...

What makes Erlang suitable for soft real-time applications?

Some background I'm working on building a programming language for digital media programming, which should support concurrency using no-sharing message passing and soft real-time (i.e. do your best to compute audio/video without losing samples or frames and with a constant throughput). It turns out that both these features are surprisi...

erlang: running "erl" I get "Fatal, could not get clock_monotonic value!, errno=22"

I have cross-compiled Erlang on a DNS-323 NAS but I get the error "Fatal, could not get clock_monotonic value!, errno=22". What am I missing? ...

need help understanding this erlang code

Hi: I'm having trouble understanding this line. [Pid2 ! {delete, V1a} || {Pid1a, V1a} <- PV1a, Pid2 <- P2, Pid1a /= Pid2 ], Here is what I understand: anything before the double pipe "||" is done repeatedly, according what's after the double pipe. so messages with delete atom is repeated sent to Pid2. I know '/=' mean inequal...

What tool do you use to build erlang program?

Emake, makiefile or...? Thank you! ...

Jinterface OtpNode initialization -name or -sname flag

When creating an OtpNode instance what kind of node is this? Is it like an erl -sname xxx or like an elr -name xxx ? ...

Erlang newbie question

Hi there, From the past few hours I am trying to install and compile beepbeep framework sample application on Win XP Pro. Hope experts here can help me! Here are the steps I am following http://www.planeterlang.org/en/planet/article/BeepBeep%5FA%5FRails%5Flike%5Fframework%5Ffor%5FMochiweb/ On step 3 when I enter the make in Erlang sh...

Erlang Web and Inets BindAddress

After installing Erlang Web 1.3 and starting it in interactive mode, I get the following error in the logs: Failed to start service: "config/inets.conf" due to: "httpd_conf: 0.0.0.0 is an invalid address" In my inets.conf I have the following: BindAddress 0.0.0.0 My sys.config: [{inets,[{services,[{httpd,"config/inets.con...

Why are C, C++, and LISP so prevalent in embedded devices and robots?

It seems that the software language skills most sought for embedded devices and robots are C, C++, and LISP. Why haven't more recent languages made inroads into these applications? For example, Erlang would seem particularly well-suited to robotic applications, since it makes concurrent programming easier and allows hot swapping of co...