parmap/2

Robert Virding robert.virding@REDACTED
Fri Feb 24 15:27:00 CET 2006


Hello Luke,

That WAS a cute function, the only thing that could have made even cuter 
was if the receive's were in parallel. Though that wouldn't affect the 
result.

Robert

Luke Gorrie skrev:
> Howdy,
> 
> I just found this function and thought it was cute enough to share on
> a rainy day:
> 
>   %% Map function F over list L in parallel.
>   parmap(F, L) ->
>       Parent = self(),
>       [receive {Pid, Result} -> Result end
>        || Pid <- [spawn(fun() -> Parent ! {self(), F(X)} end) || X <- L]].
> 
> 
> 



More information about the erlang-questions mailing list