I wrote an Erlang module where not all the internal functions are directly called. Instead, there's a couple functions that look something like this:
weird_func(Cmd, Args) ->
?MODULE:Cmd(Args).
It's a simplified example, but you get the idea. The Erlang compiler spits out warnings about unused functions, when in fact they are actu...
Suppose you have a simple function, which can get quite expensive for large values:
fact(0) -> 1;
fact(N) -> N * fact(N - 1).
Where can I find a simple example of caching (or memoizing) function values by using dets?
Any other way for easy memoization would be highly appreciated.
...
After several attempts I finally managed to compile and install both wxWidgets 2.8.11 and Erlang R13B04 with wxErlang on my Mac OS X, Version 10.4.11. However, testing wxErlang fails immediately:
1> wx:new().
= ERROR REPORT==== 21-Jul-2010::18:37:23 === WX failed loading
"wxe_driver"@"/usr/local/lib/erlang/li/wx-0.98.5/priv/i386-appl...
Hi all,
I will probably use javascript to develop an online board/card game.
My approach will be to have a client that will be able to work in standalone mode, so it must enforce rules. That means for example, if a player can't play a card, he or she shouldn't even be able to play it. This is to enhance the user experience.
The idea he...
So, Erlang is a real joy to work with, but there's one problem I run into occasionally, that I'm wondering if there is a nicer way to solve. Often, I find myself needing to split several items from a list. The syntax for splitting a list into a Head and Tail is straight forward enough, but what about when there are multiple items.
1> Li...
The actor model is nicely described by Gul Agha on his technical report, "Actors: a model of concurrent computation in distributed systems".
On page 49 he explains the "become" command:
become <expression>
After calling "become X", an actor will forward all his messages to another actor's mailbox (X).
I'm not sure, however, how this...
In Erlang I was able to immediately understand the notion of a 'node' - a self-contained Erlang VM. I could start a node on one machine with erl -name gandalf -setcookie abc, and another node on another machine (on the same LAN) with erl -name bilbo -setcookie abc. I could then spawn processes on gandalf which would communicate magically...
I have a erlang string which may contain characters like & " < and so on:
1> Unenc = "string & \"stuff\" <".
ok
Is there a Erlang function somewhere that parses the string and encodes all the needed HTML/XML entities, such as:
2> Enc = xmlencode(Unenc).
"string & "stuff" <".
?
My use case is for relatively short s...
I'm digging into Ejabberd but I can't find a way to inspect its Mnesia tables.
Is there something like the mysql shell to inspect tables?
...
Playing with Erlang, I've got a process-looping function like:
process_loop(...A long list of parameters here...) ->
receive
...Message processing logic involving the function parameters...
end,
process_loop(...Same long list of parameters...)
end.
It looks quite ugly, so I tried a refactoring like that:
process_l...
I am using Erlang for driving robot.
I am reading sensor values in C program and want to send these sensor values(multiple sensor values) to Erlang program where I can perform computation and control robot.
In progam given in Erlang book we can send multiple argument but we get back only one argument as result.
for sending X and Y to...
Between nodes, message are (must be) passed over TCP/IP. However, by what mechanism are they passed between processes running on the same node? Is TCP/IP used in this case as well? Unix domain sockets? What is the difference in performance between "within node" and "between node" message passing?
...
In Erlang, you are encouraged not to match patterns that you do not actually handle. For example:
case (anint rem 10) of
1 -> {ok, 10}
9 -> {ok, 25}
end;
is a style that is encouraged, with other possible results resulting in a badmatch result. This is consistant with the "let it crash" philosophy in Erlang.
On the other hand...
A faithful implementation of the actor message-passing semantics means that message contents are deep-copied from a logical point-of-view, even for immutable types. Deep-copying of message contents remains a bottleneck for implementations the actor model, so for performance some implementations support zero-copy message passing (although...
Hi.
I have a little problem with threads in Erlang NIFs. You can view my code here: http://pastebin.com/HMCj24Jp. The problem is that when I starting the thread it takes some arguments and starts the generate_binary function. This is okay but when I'm trying to read the arguments everything crashes.
It's perhaps not the most complex pr...
Hi all,
I am looking for a easy to learn Actor library or framework for Python 2.x
I have tried Candygram and Twisted but I did not like none of them.
I'd like something will be easy to extend to suppero Greenlet (= stackless python).
Candygram is too old.
Twisted is too complicated.
Gevent: it is unclear if it can support Actors mod...
Message-passing is a fundamental part of Erlang. Alan Kay has argued that message-passing is a concept more important than objects in his view of object-oriented programming (and he "invented" the term!).
Can Erlang be considered an object-oriented programming language (à la Smalltalk)?
...
Hi, I'm looking for a simple (small) opensource project in erlang, from which I can learn.
I've already found a promising looking one: http://github.com/mochi/mochiweb
Can you guys suggest more? Thanks!
...
There is this index function in "Erlang Programming":
index(0, [X|_]) -> X;
index(N, [_|Xs]) when N>0 -> index(N-1, Xs)
Isn't the guard "when N>0" superfluous because of the pattern matching? Calling index(0, List) will never end up in the second clause so N will always be > 0. Or am I totally wrong here?
...
Emacs is the IDE of choice for programming Erlang.
There are plenty of good modes (distel, erlware-mode, the default erlang mode,...), but what are your recommendations for setting up Emacs for professional Erlang development?
...