[CM] nested loop question .. an example

taube@uiuc.edu taube@uiuc.edu
Tue, 11 May 2004 17:04:22 -0500


there are a number of ways to do what you want. but your
example fails only because you need to pass a FLAT list of
events to the events function. You can do this by changing
your outer 'collect' clause into an 'append' clause:

(new cycle
      :notes '(c2 d2 ef3)
      :name 'some-notes)

(define (doit num )
    (let ((when 0))
      (loop repeat num
            for i = (next #&some-notes #t)
            APPEND
            (loop for j in i
                  do (setf when (+ when .5))
                  collect (new midi
                               :time when
                               :duration .5
                               :keynum j)))))

(events (doit 60 ) "test.mid")

---

ill send a different approach tomorrow.