< Back to IRCAM Forum

Nested loops construction

Hello,
I am trying to program the following with the om-loop construction using “loop-list”, “collect” and “iterate” but without success so far. I would really appreciate, if somebody could help me with this. Best, Achim

;; input: (setf pitch-lists '((nil nil 7290 7290 7290 7290 7290 7290 7290 7290) (nil nil 5974 5974 5974 5974 5974 5974 5974 5974) (nil nil nil nil 7832 7832 7832 7832 7832 7832) (nil nil nil nil 6978 6978 6978 6978 6978 6978)))
(lambda ()
  
(lambda (pitch-lists)
  (loop for i in pitch-lists
        collect
        (loop for j in i   
              collect
               (if (equal j nil) -500 500))))

;; output: ((-500 -500 500 500 500 500 500 500 500 500) (-500 -500 500 500 500 500 500 500 500 500) (-500 -500 -500 -500 500 500 500 500 500 500) (-500 -500 -500 -500 500 500 500 500 500 500))

Here’s the transcription of your code

Thanks a lot. That’ll help.
Achim