Recently a feature I was working on required me to alter a unique constraint which existed upon a table column.
The invariant had now been weakened to allow storing of duplicate email addresses based on if they share an equivalent link_id (excluding NULL).
Sadly the ease in which I was able to add the general unique constraint had disappear.
However, I was able to take advantage of insertion/update triggers to again provide me with these invariant reassurances.
Over the past couple of years I have transitioned from boilerplate-heavy, imperative code, to begin using the more intuitive map, filter and reduce higher-order functions.
In this article I hope to highlight the transformation that occurs, along with simplification, when moving away from the imperative and onto the declarative.
We shall be performing a simple process which transforms a collection of user entries into a filtered collection of their names.
Although trivial in nature, it is a great place to highlight the power of the paradigm shift.
Who doesn’t miss the the blink tag that was ever-present in years past.
I thought it would be fun to quickly code up a JavaScript implementation which replicated the functionality that has ‘sadly’ been removed in modern browsers.
Sometimes you look at a feature request and think that it maybe a very tricky implementation to develop.
I felt this way in regard to recording input fields in an recent application I have been working on.
The idea was to be able to record a user’s interaction with a HTML component (in this case a textarea), and be able to replay these events (in real-time) at a later date.
Thinking about how I would go about creating such an implementation in trivial JavaScript, with all the browser nuances and user input differences, was not very appealing.
The next sorting algorithm I have decided to explore is the Insertion-sort.
This sorting technique can be completed in-place, however, using Clojure we will instead be using a reduce to accumulate the final sorted collection.
Each element is iteratively inserted into a ‘new’ collection which maintains a sorted invariant as shown in the implementation documented below.