Hi,
I cannot for the life of me get lists:keyfind to work as I expect in Erlang.
I have the following eunit test:
should_find_key_test() ->
NewList = lists:keystore("key", 1, [], {"key", "value"}),
Value = case lists:keyfind("key", 1, NewList) of
false ->
notfound;
{_key, _value} ->
_val...
I recently ran into a bug where an entire Erlang application died, yielding a log message that looked like this:
=INFO REPORT==== 11-Jun-2010::11:07:25 ===
application: myapp
exited: shutdown
type: temporary
I have no idea what triggered this shutdown, but the real problem I have is that it didn't restart itself. Instea...
Okay so I started learning erlang recently but am baffled by the errors it keeps returning. I made a bunch of changes but I keep getting errors. The syntax is correct as far as I can tell but clearly I'm doing something wrong. Have a look...
-module(pidprint).
-export([start/0]).
dostuff([]) ->
receive
begin ->
io:form...
Hi
I have two tables one notes and one tag and I want to make the id from notes primary key to use it in the tag table, but I don't know where I do wrong. My notes id is generate from another table counter, with the function dirty_update_counter.
My function for the id_notes from tag looks like this:
Fun = fun() ->
...
I have a simple record structure consisting of a header (H) and a list of the data lines (D) 1:N. All header lines must start with a digit. All data lines have a leading whitespace. There also might be some empty lines (E) in between that must be ignored.
L = [H, D, D, E, H, D, E, H, D, D, D].
I would like to create a list of record...
I am trying to inspect the messages a node receives from other nodes, but in some other manner other than flush(), because the message size is rather big and it doesn't help. Also, I can see the messages with erlang:process_info(self(), messages_queue_len)., but I would like some way of extracting one message at a time in some kind of va...
I have searched the internet for drivers to connect to either database and all the projects I have seen have either been dead for a long time, look incomplete, or don't have good enough documentation to be usable without reading all the source.
Has anyone used Erlang to talk to either MySQL or PostgreSQL before and what sort of package ...
I am in trouble finding API for the "local Erlang client" for Riak.
Here is what Riak wiki says:
The local Erlang client is a tightly-integrated part of Riak and the Riak REST interface uses the Erlang client internally. You can find more information about the Erlang-native driver in the edoc API.
The link redirects to the main wi...
I have an sample module
-module(helloworld).
-compile(export_all).
main() -> io:format("~s~s~s~n",["\e[31m","Hello world!","\e[0m"]).
When I build:
erlc helloworld.erl
After that, I run:
erl -noshell -s helloworld main -s init stop
Hello world! (with red color)
erl -noshell -s helloworld main -s init stop > te...
Is there a recommended way to "bootstrap" an Erlang distribution? I would like to run erlang on the bunch of machines where I do not have root elevation nor development tool-set (no compilers etc ...) . My thinking was to pre-package (on the machine with the same architecture) as much as I can before. What are the minimal requirements fo...
I would like to reset passwords on a bunch of boxes over SSH. Any pointers on how Erlang could be used for this purpose?
...
I have read about how the fail-fast style of programming in languages like Erlang end up with much shorter programs than the defensive style found in most other languages. Is this correct for all types of programs and what is the reasoning for this?
...
I have a basic mochiweb polling loop that looks like the following, except it does other things instead of printing to the console and eventually returns:
blah() ->
io:format("Blah")
blah()
loop(Req) ->
PathParts = string:tokens(Req:get(path), "/")
case PathParts of
["poll"] ->
blah()
This works great until the cl...
How do I write a pattern that will bind a variable to the second
element in this tuple {<0.206.0>, {rect, 10, 30}}?
I.e. "thing in place of pattern here" that results in
Shape having the value {rect, 10, 30}.
Pattern = {<0.206.0>, {rect, 10, 30}}
It's the <0.206.0> part that is confusing me.
...
I am currently using Inets with the following request:
http:request(put, {Url, [{"User-Agent", UA}, {"Content-type", "application/json"}]}, Bodytext, []),
But the request fails.
Any suggestions?
...
I've got an Erlang snippet here that I'd like to work into more idiomatic Erlang, rather than a crude Python translation.
Process takes a pairs of congruent lists and combines them. Some of the elements need to be taken from one lists or the other, based on their properties, while the rest of the elements need to be summed. It works pro...
Hi,
I am very new to Erlang and as part of my learning exercise, I would like to write an HTML parser in Erlang.
I want to extract certain values from a web page, perhaps using a pattern to describe what data I want to extract.
Can anybody offer me some high level advice as to how they would approach this problem in Erlang?
I think I...
What is the best practice to accessing a single running mnesia node from another Erlang shell to only view data in the tables?
I tried opening two shells and pointing them to the same mnesia directory location which I realized was a very bad idea after finding this in the documentation.
-mnesia dir Directory. The name of the directory...
Hey all,
This is probably something very basic, but my Erlang installation is doggedly rejecting my calls to the re module with error:undefs. It accepts the regexp package, however, so I'm thinking its a version issue.
I'm running v. 5.6.2, and -import(re, [...]). at the top of my file, are there any other gotchas I may be missing? I...
I have a simple server:
-module(simple_server).
-export([loop/0]).
loop() ->
receive
{fact, N, Sender} ->
Sender ! {factResult, fact(N), self()},
loop();
{fib, N, Sender} ->
Sender ! {fibResult, fib(N), self()},
loop();
{stop, Sender} ->
Sender ! ok
end.
fact(0) -> 1;
fact(N...