Created
April 1, 2011 04:50
-
-
Save johnmn3/897755 to your computer and use it in GitHub Desktop.
Like partition, but adds padding at the end of the last sequence so that last sequence's size is equal to "si
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 end-padded-partition [size acoll] | |
(loop [new-coll [], coll acoll)] | |
(if (empty? coll) | |
new-coll | |
(recur | |
(let [next-stuff (vec (take size coll)) | |
padding-size (- size (count next-stuff)) | |
padding (rand-bytes padding-size)] | |
(if (zero? padding-size) | |
(conj new-coll next-stuff) | |
(conj new-coll (into next-stuff padding)))) | |
(drop size coll))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment