 
 (defn- badness
   "given line and page width returns measurement how `pretty` the line is"
-  [line-lens page-width]
-  (let [total-length (+ (reduce + line-lens) (count line-lens) -1)] ;; remember to count whitespaces
+  [words-lengths page-width]
+  (let [total-length (+ (reduce + words-lengths) (count words-lengths) -1)] ;; count whitespaces too
     (if (> total-length page-width)
       js/Infinity
       (let [a (- page-width total-length)] (* a a a)) )))


(enable-console-print!)

;;;; TODO filter out empty words
;;;; TODO precalc badness to hash ?
;;;; TODO remove has-memo?

;;;;
;;;; consts
;;;;
(defonce invisible-char (gstring/unescapeEntities "&nbsp;")) ;; \u00A0 ?




(defonce state (atom []))

(defn- set-state    [new-state] (swap! state (fn [] new-state)))
(defn- clear-state  [] (set-state []))
(defn- update-state [new-lines] (set-state (concat @state new-lines)))


;;;;
