3 ms·
So, that thing I mentioned yesterday that I wrote 35 years ago? It might interest you: https://github.com/slburson/misc-extensions Look in src/gmap.lisp.
by ScottBurson 12y ago
So, that thing I mentioned yesterday that I wrote 35 years ago? It might interest you:
https://github.com/slburson/misc-extensions
Look in src/gmap.lisp.
I admit it wouldn't work that well for 'n-at-a-time', but here's a closely related example:
(defun alist-to-plist (alist)
(gmap :plist nil (:alist alist)))
There are some idiosyncrasies here: 'nil' is shorthand for the identity function (in this case, the two-argument, two-value identity function), and the use of keyword symbols is weird and potentially problematic, though I've never run into a problem with it in practice.
This is the map-reduce model of iteration -- obviously not with support for distributed computation, but nonetheless useful for programming in the small. And far more elegant, to my eyes, than that LOOP monstrosity :-)