Page 1 of 1

ERROR: Duplicate Binding in LOOP: (result)

Posted: Sun Feb 12, 2012 10:29 am
by username652719

Code: Select all

(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)

Re: ERROR: Duplicate Binding in LOOP: (result)

Posted: Mon Feb 13, 2012 2:10 am
by Kompottkin
When using collect into, you are not expected to bind the variable specified somewhere else. It will be bound by collect into. Therefore, the with result = nil clause will cause a conflict.

(Unrelated: finally return result should read finally (return result).)