I'm working my way through some simple programs for learning Erlang, and whenever I try to use the debugger I get "Invalid beam file or no abstract code: test_module" and nothing interesting happens. It looks to me like I'm compiling my modules without debugging symbols, but I can't seem to find how to fix it.
Here's what I do:
>c(test...
I have a list of tuples which are http headers. I want to convert the list to a JSON object. I try mochijson2 but to no avail.
So I have the following :
[{'Accept',"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"},
{'Accept-Charset',"ISO-8859-1,utf-8;q=0.7,*;q=0.7"},
{'Accept-Encoding',"gzip,deflate"},
{'Accept-La...
Hi everyone,
I have a little issue to which I can find no easy answer.
I set:
Who = apple.
Message = [{apple, {0,0,0}}, {orange, {1,1,1}}].
Old = [X || {Who, X} <- Message].
Old returns as [{0,0,0},{1,1,1}]
Of course my expected response was {0,0,0}
Instead I get both apple and orange.
What could I do??
...
How can I delete a tuple with key from a list?
Ex:
TupleList = [ {apple, {0,0,0}}, {orange, {0,0,0}}, {bannana, {0,0,0}}]
Then I need to delete the tuple whos key matches orange.
So I should get back
[ {apple, {0,0,0}}, {bannana, {0,0,0}}]
Im looking for a BIF instead of a function as I am using right now.
Thanks and Regards
...
I am struggling to find any decent links to design patterns, best practice or good, basic architectural principles that should be used in building Actor-based apps. Those few that I know of are:
Blog posts, articles, WIKIs, guides
OTP Design Principles User's Guide
Patterns and Best Practices for Enterprise Integration (in general, c...
Is it possible to write a faster equivalent to this function?
prepend(X, Tuple) ->
list_to_tuple([X | tuple_to_list(Tuple)]).
...
Im having some trouble with the erlang wx module.
My program runs as follows:
Server = wx:new(),
Frame = wxFrame:new(Server, -1, "" [{size,{700, 600}}]), %%%REFERENCE TO WINDOW
Panel = wxPanel:new(Frame), %%% REF TO PANEL IN FRAME
Then I pass Panel to another process and try to create a Grid
XreportZ = wxGrid:new(Panel, 24, [ {p...
I noticed that messages sent to the pid of a gen_fsm process are matched in the state callbacks as events. Is this just accidental or can I rely on this feature?
Normally I would expect general messages sent to a gen_fsm to show up in the handle_info/3 callback and thought I would have to re-send it using gen_fsm:send_event.
Does gen_...
Is there a way to get a registered name if you have a PID?
...
Erlang-sqlite3 uses a port driver to connect with the SQLite database, and receives messages from the port:
wait_result(Port) ->
receive
{Port, Reply} ->
% io:format("Reply: ~p~n", [Reply]),
Reply;
{error, Reason} ->
io:format("Error: ~p~n", [Reason]),
{error, Reason};
_Else ->
io:format("Else...
Can an OTP event manager process (e.g. a logger) have some state of its own (e.g. logging level) and filter/transform events based on it?
...
Hello
I have a file mkList.txt (but my mkList, have 100 lists with 100 numbers)
[[22,4,55,7..],[77,3,66,23..],[44,56,23,90..]...]
And
I need to know the time that Erlang uses to read the file list using
map/sort and pmap/sort. I did this:
-module(teste).
-export([teste/1]).
-import(lists, [map/2]).
-import(lib_misc, [pmap/2]).
tes...
Hello,
I have python's based soap server and tried to call it functions using erlang (yaws_soap_lib based) soap client:
1> inets:start().
ok
2> yaws_soap_lib:call("http://127.0.0.1:90/soap/system/wsdl","cpu_count",[]).
{ok,undefined,undefined}
here is what I was able to see with tcpdump program (answer of server to client):
HTTP/1.1....
How does one split a list which is passed as an argument to a function and tag each element with a number?
The problem I have is how to increment in erlang as there are no for loops.
Thanks
...
How can I do dynamic pattern matching in Erlang?
Supose I have the function filter/2 :
filter(Pattern, Array)
where Pattern is a string with the pattern I want to match (e.g "{book, _ }" or "{ebook, _ }") typed by an user and Array is an array of heterogenous elements (e.g {dvd, "The Godfather" } , {book, "The Hitchhiker's Guide to t...
I'm trying to write a simple server that talks to clients via tcp. I have it sending messages around just fine, but now I want it to interpret the messages as Erlang data types. For example, pretend it's HTTP-like (it's not) and that I want to send from the client {get, "/foo.html"} and have the server interpret that as a tuple containin...
What's the best way to integrate erlang and python?
We need to call python functions in erlang and call erlang functions in python. At this moment we are trying to use SOAP as a intermediate layer between these two languages, but we have a lot of "not compatible" troubles. Could you advise the best way to perform integration?
...
I have quite a lot of code written in Erlang, which I want to include in applications written in Objective-C, eg on the iPad. Ideally I would want to have an object that encapsulates the Erlang run-time; this could then be accessed like the standard Erlang shell, something along the lines of:
ErlangRT *runtime = [[ErlangRT alloc] init];...
How does one sort a list in Erlang depending on a tag for each element?
If I have a process which loops and receives a single value from multiple processes and then I want to arrange the list according to the tag(which is an index) as an element is received.
How does one do this without using BIFs?
I currently do the following but wou...
I want to know if a list contains any value more than once. Here's what I have.
has_dupes(List) ->
has_dupes(List, []).
has_dupes([Item|List], Seen) ->
case lists:filter(fun(Elem) -> Elem == Item end, Seen) of
[] ->
has_dupes(List, [Item|Seen]);
_ ->
true
end;
has_dupes([], _Seen) ->
...