Re: More Concise or Idiomatic Max Sub-Array?

2012-09-30 Thread noahlz
Great use of reductions. Thanks! On Saturday, September 29, 2012 11:10:27 AM UTC-4, Jean Niklas L'orange wrote: Is there a more concise implementation, perhaps using `filter` or merely by making the `reduce` version more idiomatic somehow? Another version I believe is more evident

Re: More Concise or Idiomatic Max Sub-Array?

2012-09-29 Thread Jean Niklas L'orange
Is there a more concise implementation, perhaps using `filter` or merely by making the `reduce` version more idiomatic somehow? Another version I believe is more evident utilizes reductions to build a list over all the *max-ending-here*s. You can then just pick the maximal value in that

More Concise or Idiomatic Max Sub-Array?

2012-09-28 Thread noahlz
I've implemented the following two versions of the Max Sub-Array problem (http://en.wikipedia.org/wiki/Maximum_subarray_problem) in Clojure, using the Kadane algorithm. First with `loop` / `recur` (defn max-sub-array [A] (loop [x (first A) a (rest A)