Reputation:
(defmethod! expand-t-setclass (pcset &optional (n 12))
:icon *PC_ICON*
:doc "
Given any member of a t-setclass, lists every member of that t-setclass.
The optional parameter N can be used to set the number of equal steps per
octave to something other than the default of 12.
Will tolerate integers out of the mod-N range in PCSET."
:initvals '((1 3 4) 12)
:indoc '("pcset or list of them"
"modulus of the pc space")
(if (listp (first pcset))
(expand-t-setclasses pcset)
(let ((t-prime (t-primeform pcset n)))
(loop with result = nil
repeat n
for x-pcset = pcset then (xpose x-pcset 1 n)
unless (member x-pcset result) collect x-pcset into result
finally return result))))
(defmethod! expand-t-setclasses (pcset &optional (n 12))
(loop for item in pcset collect (expand-t-setclass item n)))
;-----
I am not too familiar with Lisp in general, and am trying to find the bug that casues this error:
ERROR: Duplicate Binding in LOOP: (result)
Upvotes: 0
Views: 201
Reputation: 139261
You have two forms in the LOOP introducing a variable RESULT.
WITH result = nil
and
COLLECT ... INTO result
Both above create a variable binding.
I would replace the COLLECT with a form which pushes the item to the RESULT list.
(loop ...
collect item into foo
...
finally (return foo))
into
(loop with foo = nil
...
(push item foo)
...
finally (return (reverse foo)))
You have another error:
FINALLY RETURN result
The LOOP syntax does not support that. FINALLY expects a compound form.
Replace it with:
FINALLY (return result)
RETURN is a defined macro in Common Lisp.
Upvotes: 1