On 23.08.2010, at 04:45, nchubrich wrote:

> I have a simulation program that runs a Number of random Simulations
> and then Averages them.  It basically looks like this:
> 
>   (reduce Average (repeatedly Number Simulate))

I guess that Simulate is a function and that Average calls functions and 
averages the result value, right?

> What is the best way of making this parallel?  I noticed there was no
> parallel version of repeatedly.  I suppose I could pmap over a dummy
> series, but this seems a misuse of the function.

That's probably the best solution to your problem, given the current state of 
paralellism support in Clojure. Compared to any naive approach using futures, 
it has the advantage of not launching too many threads at a time in order to 
prevent a loss of efficiency. Using pmap this way doesn't look like misuse to 
me, but that's obviously a matter of taste.

> Also, couldn't there be in theory a preduce?

Certainly. However, its semantics require a careful definition if you want to 
be able to use it efficiently. With the semantics  of the standard reduce, you 
couldn't profit from the associativity of addition, for example. Moreover, for 
your application, you would have to combine it with pmap anyway if, as I 
assume, your simulation takes much more time than the calculation of the 
average.

> This seemed to be in clojure.parallel, but parallel is deprecated.  Why is it 
> deprecated,
> and what's the replacement for it?

I'd like to know that as well!

Konrad.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to