with-past-values ({var | {(var [length [value*])}+}) {form}*) [Macro]

Maintains length number of past values of each var, which may be variables or a slot names. Length defaults to 1. If length is specified, then up tolength number of explicit initial past values may also be supplied. If initial values are not specified they default to nil.

Forms in the body of the macro access previous values using the past-value macro:

past-value (var nth [default])

Returns the nth past value of var, or default if the past value is nil.

Example:

? (algorithm pv midi-note (length 6 rhythm 1 duration 1 amplitude .1)
    (setf note (between 1 2))
    (with-past-values ((note 2 'a4 'b4))
      (setf note (+ 60 count))
      (format t "~%note=~S note[1]=~S note[2]=~S"
              note (past-value note 1) (past-value note 2))))
#<ALGORITHM: Pv>

(run-object #!pv 0)
note=60 note[1]=A4 note[2]=B4
note=61 note[1]=60 note[2]=A4
note=62 note[1]=61 note[2]=60
note=63 note[1]=62 note[2]=61
note=64 note[1]=63 note[2]=62
note=65 note[1]=64 note[2]=63


Last Modified: 5-Mar-1998