obfuscation.erl

Posted by stoyan

Luke Gorrie’s comment to ‘Erlang: parallel-map and parallel-foreach’ article

Parallel map brainfsck implementation in Erlang:
%% 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 ]
  ].

The notation [ F(X) || X <- L] means “The list of F(X) such that X is taken from the list L” .

Comments

Leave a response