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
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
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)