[racket] Looping with look-behind and look-forward

From: Harry Spier (vasishtha.spier at gmail.com)
Date: Sun May 27 09:30:11 EDT 2012

Is the "for" form a macro?  And if so how difficult would it be to
make a new form "for-with-look-around" that had built in look-back and
look-ahead operators (next x) (prior x) (  next?) (prior?).

So you could do something like:

((define (running-average-of-3 l)
    ([x (in-list l)])
    (unless? (or (prior?) (next?))
                 (displayln (/ (+ x (prior x) (next x)) 3))))))

Posted on the users mailing list.