Loving Annoying Things

I’ve been absorbing quite a bit of content from Gary Vaynerchuk lately. I really like his idea of not making excuses and getting to work and eating dirt and loving the process. I mean, it’s hard to argue against those things and risk being associated with negative things; despite that, I personally don’t deny they are good ideas. How much weight you give them is up to you.

To relate eating dirt and loving the process to my title for this post: learning Clojure has been an annoying process, but a very interesting one.

In the last two weeks, I’ve got through 4 or 5 chapters of Clojure for the Brave and True by Daniel Higginbotham, the full book here. The book really started to click for me once I hit the fifth chapter on functional programming.

I know that’s when it clicked because while I was reading, I was also trying to practice coding problems on CodeWars. I was very lost for the first week and a half- I just couldn’t figure out how to get around the immutability of the data structures in Clojure. Also, the whole “operating on lists/sequences” to make other sequences was a simple enough idea to wrap my head around. However, using that to solve a problem was a real head scratcher.

Anyway, the moral of the story is that the Clojure standard library is vast and extensive. And while I have the right idea of how to approach some of these more basic problems I am encountering, I should go look for the function that does it already, instead of implementing it myself.

Here’s the piece of code in question:

;; Given `num` = 10x+y, 
;; return some `val` = x - 2y

;; My version 
;; - Complained if num was too big
(defn decomp [num]
    (- (/ num 10) (* 2 (mod num 10)))
;; The Good Version
(defn decomp [num]
    (- (quot num 10) (* 2 (mod num 10))))

Thanks for reading this post! Comments, questions, and feedback are always welcome.