Archives for erlang

A problem I ran across

I was chasing links concerning the lack of tail recursion optimization in ruby and ran across a math problem:
Find the smallest positive integer n such that n % x = x-1 for x from 2 to 18
i.e. The remainder is one less than the divisor for all integral divisors from 2 to 18.

The [...]

Erlang surprises me.

I recently wanted to calculate some binomial coefficients in Erlang, and so needed an implementation of the factorial function. No problem. The factorial function is the canonical illustration of how to define a recursive function in Erlang. It goes something like this:
fac(0) -> 1;
fac(N) -> N * fac(N-1).

I have to confess that definition has always [...]

Intro to gen_fsm and gen_server

Emacs

erl process handling commands

Note to self: some handy erlang shell commands for dealing with processes.
process_info(Pid)
i()
erlang:processes(), or better yet, rp(erlang:processes()). Sometimes long lists show “…” to represent the tail elements. Wrapping in rp() shows the whole list.
Finally, exit(Pid, kill) to kill the process represented by Pid. For a while I thought that exit(Pid) sufficed, but some experimentation [...]

man page support in erlang-mode

I want to record what I had to do to get man page support working correctly in emacs erlang-mode under Ubuntu Hardy Heron.
First, set the erlang root directory for erlang-mode:

(setq erlang-root-dir “/usr/lib/erlang”)

Next put a symbolic link to the man pages in the erlang root directory.

cd /usr/lib/erlang
sudo rmdir man #the man dir installed by [...]

upcoming Pragmatic book on Erlang

Kevin Smith of Hypothetical Labs has let the cat out of the bag.

I’m currently writing a Erlang book for the Pragmatic Bookshelf. The book’s focus will be practical development using Erlang. It will cover OTP, mnesia, web programming (Yaws, Mochiweb, Erlyweb), and a few miscellaneous topics such as XML parsing and unit testing.

I [...]

OOP in erlang

I read this quote on the blog of Isaiah Perumalla, in the post called My Journey to Smalltalk:

“OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which [...]

ejabberd

I’m interested in learning a bit about the Jabber/XMPP protocol. There’s only one way I know to do so, and that is to mess with it. So I decided to install a Jabber server, ejabberd.
Installing ejabberd on Ubuntu is easy, but I hit an immediate roadblock: ejabberd has a web-based administrative interface, but following installation, [...]

recursion in erlang

Some months ago Kevin (check him out at Hypothetical Labs) started the RDU erlounge, a monthly meeting of area erlang enthusiasts. The meetings were organized via a mailing list. Recently one of the guys on the list, Jared (Alloy Code), asked for a bit of help. He was working an exercise (a function to compute [...]

sum of file sizes

This was recently posted to the erlang-questions mailing list
I am trying to grok how to write a simple ‘du’ like program that walks a directory structure ( not just one but all nested directories ) and calculates a sum of all the file sizes. I found some sum() code that I understand how that works.
I [...]