Created
December 30, 2015 21:42
-
-
Save timmc/35c969e97ac1c5e7f72f to your computer and use it in GitHub Desktop.
This file contains 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 bucket-nums | |
[width start xs] | |
(loop [buckets [] | |
stream xs | |
threshold (+ start width)] | |
(if (empty? stream) | |
buckets | |
(let [[under beyond] (split-with #(< % threshold) stream)] | |
(recur (conj buckets under) | |
beyond | |
(+ threshold width)))))) | |
(bucket-nums 1000 0 [1 35 456 2005 3045 3987]) | |
;;= [(1 35 456) () (2005) (3045 3987)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment