Created
April 3, 2015 06:29
-
-
Save icambron/369d568bf6d5478e59b8 to your computer and use it in GitHub Desktop.
free samples
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 eat-well [vendors] | |
(loop [[[item & others] newest older oldest] [vendors 0 0 0]] | |
(if item | |
(recur [others (+ item (max older oldest)) newest older]) | |
(max newest older oldest)))) | |
(eat-well [1 4 3 12 4 3 3 4]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alex's formulation is equivalent but slightly nicer; it just does the
max
one step earlier.