[erlang-questions] Good one-liners?

Joakim G. jocke@REDACTED
Wed Mar 28 01:53:38 CEST 2007


Christian S wrote:
 >> Hi, I keep seeing these perl programmers in teeshirts with one-liners printed on them. It made me think about what erlang one-liners I would want on a teeshirt.

 From the top of my head. A four-liner parallel map perhaps:

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

as a single-line:

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

It all depends on your t-shirt size I suppose. :-)

Cheers
/Jocke



More information about the erlang-questions mailing list