Last active
January 7, 2016 03:23
-
-
Save domgetter/02fbe16020dd8b481d83 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 words-rows-reducer [row-length [full pending] word] | |
(let [total-chars-of-word-and-pending (apply + (count word) (map count pending)) ; this could be fancier, taking into account space width and individual letter width | |
adding-word-would-overflow-row (> total-chars-of-word-and-pending row-length) | |
store-pending-and-make-new-row (delay [(conj full pending) [word]]) | |
add-word-to-pending (delay [full (conj pending word)])] | |
(if adding-word-would-overflow-row | |
@store-pending-and-make-new-row | |
@add-word-to-pending))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment