>
> 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 list, giving you the maximal subarray:

(defn max-subarray [A]
  (let [pos+ (fn [sum x] (if (neg? sum) x (+ sum x)))
        ending-heres (reductions pos+ 0 A)]
    (reduce max ending-heres)))

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