Re: How to write performant functions in clojure (and other functional languages)

2009-07-26 Thread John Harrop
On Sat, Jul 25, 2009 at 4:40 PM, atucker wrote: > > I wonder if any of the Clojurians on here might like to describe how > one might write the factorial function as a parallel one? Taking > advantage of the associativity of multiplication, along the lines of > > 16! = (((1*2)*(3*4)) * ((5*6)*(7*

Re: How to write performant functions in clojure (and other functional languages)

2009-07-26 Thread prhlava
Hello, > I wonder if any of the Clojurians on here might like to describe how > one might write the factorial function as a parallel one? Look at the files section of this group, I wrote 2 examples of parallel factorial and the sources are uploaded there... Kind regards, Vlad --~--~--

Re: How to write performant functions in clojure (and other functional languages)

2009-07-25 Thread Timothy Pratley
The parallel library wraps the ForkJoin library scheduled for inclusion in JDK 7: http://gee.cs.oswego.edu/dl/concurrency-interest/index.html You'll need jsr166y.jar in your classpath in order to use this library. (use '(clojure.parallel)) (clojure.parallel/preduce * (range 2 16)) On Jul 26, 6:40

Re: How to write performant functions in clojure (and other functional languages)

2009-07-25 Thread atucker
I wonder if any of the Clojurians on here might like to describe how one might write the factorial function as a parallel one? Taking advantage of the associativity of multiplication, along the lines of 16! = (((1*2)*(3*4)) * ((5*6)*(7*8))) * (((9*10)*(11*12)) * ((13*14)* (15*16))) On Jul 24, 8

Re: How to write performant functions in clojure (and other functional languages)

2009-07-24 Thread Daniel Lyons
Jeremy, On Jul 24, 1:20 pm, Jeremy Gailor wrote: > I'm just looking for general optimizations that I should be aware of, the > nature of the function itself isn't really important.  I could turn to > number theory to get some performance improvement, but from a Clojure > oriented perspective, wh

How to write performant functions in clojure (and other functional languages)

2009-07-24 Thread Jeremy Gailor
I'm pretty familiar with scheme programming, so functional programming isn't new to me, but I rarely turn to it for solving problems during my day to day work. In learning Clojure, I've been going through problems on project euler, and one question I have is that while it's straigh-forward to impl