Thanks - did not post reply properly - this is very useful, as is the prior example in a different way (yours does not seem to allow the list of iteration variables to be provided dynamically, e.g., as a list, the prior has no such list, but I can index into the values). Both can fit my needs though.<br>
<br>What a great user group!<br><br>Thanks again,<br>Rob<br><br><div class="gmail_quote">On Tue, Mar 13, 2012 at 5:09 PM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
May I propose a slightly more useful macro instead:<br>
<br>
#lang racket<br>
<br>
(define-syntax (myfor stx)<br>
(syntax-case stx ()<br>
[(_ (i ...) for-clause todo ...)<br>
#'(for* ([i for-clause] ...) todo ...)]))<br>
<div class="im"><br>
(define (nestfortest . args) (displayln args))<br>
<br>
</div>(myfor (a b c) '(1 2)<br>
(displayln `(,a ,b ,c)))<br>
<div><div class="h5"><br>
<br>
<br>
<br>
On Mar 13, 2012, at 8:02 PM, rob cook wrote:<br>
<br>
> To add to prior query - here's what I did, but I just think there *must* be a more elegant solution.<br>
><br>
> (define (nestfor depth forclause todo)<br>
> (define (nf depth forclause todo resultant)<br>
> (for ((x forclause))<br>
> (if (= depth 1)<br>
> (apply todo (append (list x) resultant))<br>
> (nf (- depth 1) forclause todo (append (list x) resultant)))))<br>
> (nf depth forclause todo empty))<br>
><br>
> (define (nestfortest . args) (displayln args))<br>
><br>
> (nestfor 3 '(1 2) nestfortest)<br>
</div></div>> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
</blockquote></div><br>