I have cards in a database with some paragraph(s) worth of text for each card. I want to replace "Specific Phrase(s)" with HTML symbols. So that when they are displayed, the phrase(s) are symbol(s) instead of text.
My code works pretty flawlessly, except for in the way I am calling the final function.
(I am going to try and not get too involved with information overload but) I am calling the final function like so:
...{:__html (add-symbols
(add-symbols
(add-symbols
(add-symbols
(add-symbols
(add-symbols
(add-symbols
(add-symbols
(add-symbols
(add-symbols
(add-symbols
(add-symbols
(:text card)))))))))))))}
The reason I am calling this function like this, is because the add-symbols function takes the "card-text" and finds the first occurrence and then returns the "card-text" or (:text card) updated in which then it's called again.
Since the first occurrence is now gone and replaced with an html encoded symbol, I can scan again and replace, etc, this number of times will cover the amount of text and frequency of symbols.
But lately, I have been brushing up on Clojure with Clojure for the Brave, and I came across and payed attention to the fn (REDUCE ...)
I knew this wouldn't be necessarily easy. But I was thinking something along the lines of just:
(reduce add-symbols (:text card))
Like I said, I knew it wouldn't be that easy, ;) but, should I just loop? or what?
My previous code works but it's so pathetic, and fully coursing thru ALL and ANY text and replacing ALL phrases no matter what the length of the paragraphs, using some keen reduce, would be ideal!
Thanks for any help!