sunspots
sunspots

Reputation: 1057

Creating a string of blank characters

How would one construct a code that inserts b blank characters in between two input strings? Concretely I am asking about a function which inputs

        (newfn "AAA" "ZZZ" 10) 

and outputs 10 blanks between the strings "AAA" and "ZZZ"

Upvotes: 0

Views: 168

Answers (1)

Alister Lee
Alister Lee

Reputation: 2455

(defn wrap-spaces [h t n]
  (let [blanks (apply str (repeat n " "))]
    (str h blanks t)))

(wrap-spaces "AAA" "ZZZ" 10)

Upvotes: 1

Related Questions