Quasiwalk is a tree-map that respects quote, quasiquote, and unquote. It’s for metaprogramming.
(quasiwalk proc tree)
Applies proc
to all the non-quoted atoms in tree
. I mean, the tree
itself contains symbolic data, obviously (as in, one level of
quotedness).
(quasiwalk (as-list reverse) '(this is '(an example)))
⇒ (siht si '(an example))
(quasiwalk (as-list reverse) '(this is `(another ,(example))))
⇒ (siht si `(another ,(elpmaxe)))
It can figure out nested levels of quasiquoting and unquoting.
The limitation in this version is that if quote
, quasiquote
, or
unquote
has been renamed in the environment, it doesn’t know that.
It works off the original names (e.g. equality to those symbols
exactly).
(quasiwalk softness proc tree)
Quasiwalk, but assume we’re already in softness
levels of
quasiquotation. Normally you won’t need this, but quasiwalk
uses it
internally.
(quasiwalk* proc tree)
This variant runs quasiwalk
for the side-effects but then doesn’t
return anything. It still does all the same consing as quasiwalk
does, it’s literally just
(define (quasiwalk* proc tree) (quasiwalk proc tree) (void))
which is sometimes useful.
git clone https://idiomdrottning.org/quasiwalk