Skip to content

Journal

Day 88 - Clojure driven finance startup and 4Clojure

Another 4Clojure challenge, this time #9 covering sets in Clojure. I like working with sets and like other main data structures they can be used like a function.

I had what will probably be the weirdest and most pointless interview of my life. The first half started well and I quickly built a positive rapport with the founder and CTO. They had ambitious plants.

The interview quickly went weird as soon as I met the 'developers' who were interviewing me. They both projected inexperience and one was incredibly nervous all the way through.

The 'lead' developer decided to completely change the approach of the interview without actually letting me know in advance. I had submitted a solution to a take-home test which I had spend a few hours on, but they completely ignored it and wouldn't let me walk through it.

A lunch with a another company with Clojure roles, cycling to and from the meeting on the Bromptom.

Day 87 - Coaching and uSwitch dojo

Cycled on my Brompton folding bike for another coaching session in Wagamama on the Southbank. The restaurant was not busy and it was quiet enough to discuss 4Clojure solutions in details.

Wagamama also has relatively healthy food and I found it a relaxing way to learn and teach Clojure. I enjoyed my Vegatsu dish with extra curry sauce.

Then a short ride over to uSwitch offices just past Tower Bridge on the South side for the London Clojurians Code dojo event.

Code from today:

Day 86 - Coaching and advent of code challenges

Cleaned up the code from the first days Advent of Code challenge.

Mentoring my friend in the USA who is learning Clojure.

Code from today

Advent of Code 2018

;; using a set

(require 'clojure.set)

;; if the adjusted frequency is used as an argument to the set,
;; then the set will return the frequency if its already there
;; otherwise the set returns nil
;; so we can then return the adjusted frequency
;; otherwise we keep going

;; Where do two maps intersect, e.g. share the same values
(clojure.set/intersection #{1 2 3} #{3 4 5})
;; => #{3}


;; Define maps for example data
(def a #{1 2 3})
(def b #{3 4 5})

;; Return a set that is the first set without elements of the remaining sets
(clojure.set/difference a b)
;; => #{1 2}

(clojure.set/difference b a)
;; => #{4 5}

;; Concatenate
(concat (clojure.set/difference a b) (clojure.set/difference b a))
;; => (1 2 4 5)

Thank you.

🌐 Practical.li Website

Practical.li GitHub Org practicalli-johnny profile

@practicalli_johnny

Day 85 - MeetAMentor Clojure Study Group

Inspired by the broadcasting by Tim Pote of his solutions to Advent of Code, I did my own spin of the first day of challenges.

Code from today

Advent of Code 2018

Advent of code day one

A new Leiningen project created with the default template. Updated licence to Creative Commons.

Note

lein new advent-of-code-2018

The first part of day one is a simple reduce + over the specific data set of frequency adjustments. Added the unique data set for day one using a different namespace as its a long data set.

To see if there was any performance difference with using either apply or reduce functions, gathered timing and bench marking results using the advent of code data set. Results show that apply is faster in this instance.

Part two was tricky as we need to manage state while we process the frequency-changes. We need to keep track of the frequencies that we adjust the device to each time.

I tried out the imperative and mutable solution (DONT DO THIS AT HOME!) that Tim Pote discussed in his broadcast and it worked, although did not feel at all like Clojure.

Then I took a functional approach with recursion, using loop and recur at a pretty low level of abstraction.

Again that worked, although the code is a little procedural and certainly not getting the most out of Clojure.

The design was evolved to using reduce and then further to use reductions to create all the intermediary results of the reduce. This made a pretty great abstraction on the design and a really simple expression.

One thing that was missing was a function similar to distinct except the just the duplicates were kept, so a simple helper function was added.


Thank you.

🌐 Practical.li Website

Practical.li GitHub Org practicalli-johnny profile

@practicalli_johnny