From f279e20468fb5323c33cbf43346c35ddef7f96e0 Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 22 Feb 2026 15:25:50 +0100 Subject: Initial commit --- src/cashflow/utils.clj | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/cashflow/utils.clj (limited to 'src/cashflow/utils.clj') diff --git a/src/cashflow/utils.clj b/src/cashflow/utils.clj new file mode 100644 index 0000000..abbd2f9 --- /dev/null +++ b/src/cashflow/utils.clj @@ -0,0 +1,24 @@ +(ns cashflow.utils + (:require [clojure.string :as cstr])) + +(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)))) + -- cgit v1.2.3