[CM] one-over-f-noise

Carl Edwards carl.boingie@rcn.com
Mon, 11 Nov 2002 00:08:58 -0500


If anyone has time to answer a simple Lisp question:

I've been looking at an old example that I found online, the
one-over-f-noise.lsp function (or pair of functions). There is a part I
don't understand in the let* form (if that's the right word) of the
second function. Here's the listing:


(defun one-over-f-noise (power-of-2)
  (let*  (rtn
          (length (expt 2 power-of-2))
          (half-range  (/ 1.0 power-of-2))
          (r (make-array (list power-of-2))))  ; bug: should free array
    (loop for n from 0 to (- length 1) do
          (push
           (one-over-f-aux n power-of-2 r half-range)
           rtn))
    rtn))

I'll append the whole program below (necessary if you want to try it at
home).

My question is regarding the variable (or function) rtn. Is "rtn" short for
something that I can't find in cltl2? Just point me in the right direction,
I just need to know what to look up.

Another sub-question is: should I worry about the documented bug? The
program seems to work just fine.

Thanks in advance,

Carl Edwards



---------------snip-----------------------------
(in-package :cm)

(defun one-over-f-aux (n power-of-2 r half-range)
  (let ((sum 0))
    (loop for i below power-of-2
          do
          (let ((pow (expt 2 i)))
            (when (not (= (/ n pow) (/ (- n 1) pow)))
              (setf (aref r i) (between (- half-range) half-range)))
            (incf sum (aref r i))))
    sum))


;;; One over f noise generator. Returns a list of size 2^power-of-2 of
;;; numbers from -1 to 1
;;; Based on Gardner (1978) and Dick Moore (1988?)

(defun one-over-f-noise (power-of-2)
  (let*  (rtn
          (length (expt 2 power-of-2))
          (half-range  (/ 1.0 power-of-2))
          (r (make-array (list power-of-2))))  ; bug: should free array
    (loop for n from 0 to (- length 1) do
          (push
           (one-over-f-aux n power-of-2 r half-range)
           rtn))
    rtn))
----------------------snip-------------------------------------