Last active
June 7, 2017 12:00
-
-
Save gphilipp/f600c3807e868ceed015283bb998b528 to your computer and use it in GitHub Desktop.
baldly written function
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 pad [n coll val] | |
(take n (concat coll (repeat val)))) | |
(defn egalize-colls [coll1 coll2 pad-item] | |
(if (= (count coll2) (count coll1)) | |
[coll1 coll2] | |
(let [smallest-coll (if (< (count coll1) (count coll2)) coll1 coll2) | |
pad-count (if (= coll1 smallest-coll) (count coll2) (count coll1))] | |
(if (= coll1 smallest-coll) | |
[(vec (pad pad-count coll1 pad-item)) coll2] | |
[coll1 (vec (pad pad-count coll2 pad-item))])))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Disclaimer: I know it's written poorly. It would be a nightmare to add an another collection to egalize.