This very useful answer suggested replacing this code:
(defun describe-paths (location edges) (apply (function append) (mapcar
Wherein:
(defun describe-paths-mapcan (location edges) (mapcan
I understand conceptually why this should work, but it is not; The second option freezes my REPL, and the CL prompt never returns. I have to restart SLIME. So I looked at it , and I wonder if the fact that mapcan is not using list , but rather nconc , is the reason? Therefore, in reality, these are not identically functioning code blocks?
For the curious, I pass this:
(describe-paths-mapcan 'living-room *edges*)
Where *edges* :
(defparameter *edges* '((living-room (garden west door) (attic upstairs ladder)) (garden (living-room east door)) (attic (living-room downstairs ladder))))
and
(defun describe-path (edge) `(there is a ,(caddr edge) going ,(cadr edge) from here.))
source share