erlang

Syntax Error while accessing a field in a record

I'm having a problem that should be stupidly easy to fix. Following this, I'm trying to access a field in a record. Here's a simplified example that exhibits my problem: -module(test). -export([test/0]). -record(rec, {f1=[], f2=[], f3=[]}). test() -> Rec = #rec{f1=[1,2,3], f3=[4,5,6]}, Fields = record_info(fields, rec), lo...

Getting the SHA hash from info dictionary in torrent file in Erlang

Hi, I have been trying to parse a torrent file in Erlang, So far I was able to extract all the general info like torrent name, files(length, path, name), tracker link... The only thing that is bothering me is the sha1 hash value. I checked many websites online and according to the specification the "info" dictionary is what needs to b...

ERLANG - WX NOTEBOOK SIZE

Hi Everyone, Im having a small issue today.. I am trying to create an aui as shown in the demo program of the wx module. The size of the actual tabs will not change no matter what I do. They stay at about 400 by 50 and I can't understand why. I think it may be when I call Manager = wxAuiManager:new([{managed_wnd, Panel}]), I need ...

Truncate a float in Erlang

Hi, I am using a function to create a list from a float. float_to_list(0.02). It returns: "2.00000000000000000000e-002" I need it to give me a number exactly like: "0.20" If I fed it 5.23 "5.23" If I fed it 5.5 "5.50" So basically the number rounded to two decimal places. Probably an easy fix. Thanks EDIT: I would like t...

Concurrent programming techniques, pros, cons

There is at least three well-known approaches for creating concurrent applications: Multithreading and memory synchronization through locking(.NET, Java). Software Transactional Memory (link text) is another approach to synchronization. Asynchronous message passing (Erlang). I would like to learn if there are other approaches and dis...

Integer to Binary Erlang

Hi, I am trying to make an integer into a binary: 543 = <<"543">> How can I do this without integer_to_list(list_to_binary(K)). ...

Erlang style concurrency in the D programming language.

I think Erlang-style concurrency is the answer to exponential growth of core count. You can kind of fake it with other main stream languages. But the solutions always leave me wanting. I am not willing to give up multi-paradigm programming (C++/D) to switch to Erlang's draconian syntax. What is Erlang-style concurrency: From one of ...

TextCtrl -> Truncate a float in Erlang

My last question leads me to this one: wxTextCtrl:setValue( TcGrossProfit, io_lib:format("~.2f",[NewGrossProfit])), generates an error from wxTextCtrl, with a bad arg. I know this is the culprit NewGrossProfit = 5.45333, io_lib:format("~.2f",[NewGrossProfit]) Thanks for the last one, hope this one's easier -B EDIT Last Questi...

Erlang - How to run more than one node on single windows vista machine?

hello i m graduate student and as my project i have to run Erlang Chat Application, but i am confused to run 2 nodes on my single machine having windows vista. can anybody help me please to run the application. regards anum ...

erlang - checksum

Godd Morning, I am trying to perform a check sum on the following function Data = [<<"9">>,"81", <<1>>, <<"52=">>, [[50,48,49,48,49,48,50,54,45,49,53,":",52,53,":",52,52]], <<1>>, <<1>>, [<<"9">>,<<"0">>,<<1>>], [<<"5">>,<<"4">>,<<1>>]] Using: checksum(Data) -> checksum(Data, 0). checksum([...

How to share username+password between 2 server ?

I need to create for my blog in PHP, a chat like facebook-chat in erlang. But I don't know how to share the username+password between APACHE and Ejabberd. How do I do this ? ...

Show your Erlang app

Can I see your ejabberd application :) ? I want see some working ejabberd application :P ...

Two-way Hash Table in Erlang

I'm trying to come up with a dictionary-like data structure that I can use in Erlang. The goal is to guarantee that all the values, as well as the keys, are unique. I can do it with explicit consistency checks after every modification, but I'm hoping there's an obscure type that does this for me. Is there one? If not, is there a better w...

writing to a Random access file in Erlang

How does one write to a file after a certain amount of data is received? I know the file can be opened and then it can be written to using file:pwrite(Position, Bin). The thing I would like to know is if data is e.g. being downloaded and needs to be written to the file. How does one do this efficiently? e.g. using a buffer(how is a buf...

Does ?assertException actually work with gen_fsm:startlink?

I have the following init method in a gen_fsm callback module (my_fsm): init(Args) when length(Args) =:= 2 -> % do work with Args here {ok, my_state, InitialState}. There is no other init-method in the callback module. I want to write a unit test using eunit where I assert that calling gen_fsm with an argument-list that does no...

Why have you used Erlang in your projects ?

Have you used Erlang in the past ? If yes, tell me why have you choose Erlang in your application and if you want, show me your Erlang app on the web ;) I want to see some "amateur" Erlang app. ...

What situation is PHP, Python, Java, C++, Erlang better in ?

In my life I have learned many program languages: C, C++, python, java, assembly, javascript, php, etc but some times I don't know what languages is better for some projects. So I want to know, in your opinion: what situation is python better in ? and Why ? what situation is c++ better in ? and Why ? what situation is php better in ?...

Check active timers in Erlang

Is there a simple way to get a list of all currently waiting timers started with erlang:send_after, erlang:apply_after, etc. in Erlang? ...

How to design a flexible Erlang protocol stack creation API

Unsatisfied with my current approach I'm just trying to redesign the way I build protocol stacks in Erlang. The feature ordered by importance: Performance Flexibility and implementation speed adding new protocol variants It would help development to explore the protocol variants from the shell My current model (alreday described in ...

Erlang shell problem

Hello, Im new to Erlang. Im using Erlang on Ubuntu 10.10. I typed erl to start the erlang shell (Eshell V5.7.4). The shell starts. But, if i type some expression in the shell like say 20+30 and hit enter im back to 1>, and the result of the expression is not shown. What could be causing this problem ? Please Help Thank You. ...