Skip to content

Instantly share code, notes, and snippets.

@gphilipp
Last active June 7, 2017 12:00
Show Gist options
  • Save gphilipp/f600c3807e868ceed015283bb998b528 to your computer and use it in GitHub Desktop.
Save gphilipp/f600c3807e868ceed015283bb998b528 to your computer and use it in GitHub Desktop.
baldly written function
(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))]))))
@gphilipp
Copy link
Author

gphilipp commented Jun 7, 2017

Disclaimer: I know it's written poorly. It would be a nightmare to add an another collection to egalize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment