Coding Zen in all the strange places

in code

I continue to return to Zen as a way to reach peace with myself. Zen encourages introspection and meditation alongside expressive acts such as calligraphy. The core of Zen calligraphy, such that I understand it, is to cultivate the beginner’s mind. The expert mind is packed with presumption; while an expert mind has a powerful ability to categorize a problem, such that it can immediately a ready-made solution, this procedural reduction prevents it from naive consideration of the actual problem as presented.

This is evident at work: I think “Aha! This task is in fact this problem with this solution!,” and then I solve it. I get faster, but I don’t grow: practice reinforces dogma. Practice strengthens your current paradigm inhibits personal development.

I bought If Hemingway Wrote JavaSciript by Angus Coll from a Humble Bundle a few months ago. The book’s comparative approaches to the same simple problem inspired me to fuse Zen naïvety and functional JavaScript. Michael Fogus’ approach in Functional JavaScript underlies my recent series of JavaScript snippets.

Snippets should be taken at face value: exercises in a base level of code that encapsulates knowledge and naive practice. What is a map? What is an elegant way to find factorials? The goal is to improve my ability to problem-solve with JavaScript without preconception.

function range(start, end) {
    if (!end) {
        end = start;
        start = 1;

    if (start > end) {
        [start, end] = [end, start];

    return [...Array(end + 1).keys()].slice(start);

function reduce(arr, sum, callback) {
    return !arr.length ? sum : reduce(arr.slice(1), callback(arr[0], sum), callback);

let adder = (number, sum) => number + sum,
    multiplier = (number, sum) => number * sum,
    numbers = range(10);

reduce(numbers, 0, adder); // 55
reduce(numbers, 1, multiplier); // 3628800

There’s quite a of Project Euler in this series, and I think this series will segue into attempts on different problems. For now, its enjoyable and I intend to continue.

Remap a JavaScript Object

in code

Blog Silence

in me

Run Clare 2019 Race Series

in running

Your email address will not be published. Required fields are marked *