Last active
August 14, 2017 03:51
-
-
Save Sophia-Gold/bec46bfcd0011b1b5e98a43f0847b399 to your computer and use it in GitHub Desktop.
from Guy Steele's talk, "Four Solutions to a Trivial Problem"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn histo-water [l] | |
| (->> l | |
| (map-indexed #(vector | |
| %2 | |
| (reduce max 0 (subvec l 0 %1)) | |
| (reduce max 0 (subvec l %1)))) | |
| (map #(- (min (second %) (nth % 2)) (first %))) | |
| (filter pos?) | |
| (reduce +))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment