(ns cashflow.utils) (defn- n*string [n string] (when (string? string) (->> (for [_ (range n)] string) (apply str)))) (defn string-min-length "Returns string `s` when length of string is `min-length`, otherwise fills string up with a `filler` character, either before `s` if `position` :before or after `s` if `position` is :after." [s min-length filler position] (when (string? s) (let [filler-string (-> (- min-length (.length s)) (n*string filler))] (cond (= position :before) (str filler-string s) (= position :after) (str s filler-string) :else s))))