Daily Shaarli

All links of one day in a single page.

Previous day

December 16, 2024

Next day

Array languages for Clojurians

As a lisp, Clojure of course qualifies as one such mind-altering substance. (It arguably qualifies again on the basis of its focus on immutability.) But Blazeski’s article points out that array-based languages such as J, its predecessor APL ("A Programming Language"), and the proprietary q are equally mind-expanding. Let’s see what was – and remains – so compelling about the array programming approach to problems, and compare it to Clojure’s approach.

One operator to do both is pretty handy. We can of course replicate each with out-of-the-box Clojure:

(map (partial + 2) [2 3 4]) ; => (4 5 6)
(map + [2 3 4] [1 2 3])     ; => (3 5 7)