One interesting thing that could be implemented as a function could be a form of generating Negative Harmony.
In the video below, there are some explanation of what it is and the origin in the Levy book.
It was a trendy topic due to the Jacob Collier interview. And there are a lot of fun videos making versions of pop tunes using negative harmony.
The way I understand it, it is simply a kind of mapping notes in relation to an axis, like in the figure below.
So we need a function that could map a note in any register to another note in the closest register to the first on.
So, any C note will be mapped to G, all Db to F#, all D to F, all, Eb to E, all B to Ab, all Bb to A.
It´s also possible to generate other mappings as well.
I think that replace map or substitute map can do the job, but I´m not sure (I will try), but I find interesting to post it here to explore the idea.
All the best,
It´s kind of funny to sse in this por versions how every is upside down and how you can generate an entirely new song from exactly the same material.
POP TUNES with negative harmony:
here is a sketch for an alternative "binary-(or element-)layer-FUNCTION
(defun element-layer (lists &key (rnd nil)) (let ((lists (if (null rnd) lists (rnd-order lists :list t)))) (car (last (loop for x in (rest lists) with list = (car lists) collect (setf list (loop for i in list with cnt = 0 when (equal i 0) collect (nth cnt x) and do (incf cnt) else collect i))))))) (element-layer (list '(1 0 0 1 1 0 0 1 0 0 0 0) '(0 2 3 0 4 5 0 6 0 7 8 0) '(11 12 13 14 15 16 17)) :rnd nil) => (1 11 2 1 1 3 12 1 4 5 13 6) ;;; hierarchic: every 0's will be replaced by the values from the next/sub-list...