dmonty
March 11, 2017, 6:39pm
1
I’m new to nyquist/lisp. Having trouble returning a SOUND object inside a DOLIST loop.
The dolist loop on line 28 returns NIL. I need the SOUNDs generated inside the loop on line 68 to be appended together outside the loop.
https://github.com/dmonty2/audacity-pemf/blob/master/pemf-list.ny
End goal is to have the user enter a list of frequencies frequeny1@pulserate1:time1,frequency2@pulserate2:time2… audacity will output a seqence of wav1,wav2,…
Thanks.
steve
March 12, 2017, 9:21pm
2
Example 1
(setf mylist (list 'a 'b 'c 'd))
(setf num 4)
(print
(dolist (x mylist)
(print x)
(dotimes (i num)
(setf i (1+ i)))))
prints:
A
B
C
D
NIL
Note that “NIL” is the return value of the ‘dolist’
Example 2
(setf mylist (list 'a 'b 'c 'd))
(setf num 4)
(print
(dolist (x mylist j)
(print x)
(dotimes (j num)
(setf j (1+ j)))))
Error.
‘j’ is local to ‘dotimes’, so as the return value of dolist it is unbound.
Example 3
(setf mylist (list 'a 'b 'c 'd))
(setf num 4)
(print
(let ((count 0))
(dolist (x mylist count)
(print x)
(dotimes (j num)
(setf count (1+ count))))))
prints:
A
B
C
D
16
Note that “count = 16” is the return value of the ‘dolist’
See also: http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/xlisp/xlisp-ref/xlisp-ref-095.htm
Does that help?
dmonty
March 13, 2017, 6:58am
3
Thanks. The script is now working.