17
votes

How can I write map-reduce functions in Erlang for CouchDB? I am sure Erlang is faster than JavaScript.

2

2 Answers

25
votes
pmap(F, L) ->
    Parent = self(),
    Pids = [spawn(fun() ->
                     Parent ! {self(), F(X)}
                  end) || X -> L],
    [receive {Pid, Res} -> Res end || Pid < - Pids].

I believe I did, Bob.

16
votes

You can do so using erlview, which is within the top ten hits on Google for "couchdb erlang view" and is listed on the CouchDB wiki page for other-language view servers.