Wow, this is amazing! Thanks a lot Christian! Jinsong
On Thu, Jul 14, 2016 at 3:05 AM, Christian Kellermann <[email protected]> wrote: > * Jinsong Liang <[email protected]> [160714 04:26]: > > Hi, > > > > I want to do nested loops over three lists like the following pseudo > code: > > > > for i in '(1 2 3) > > for j in '(4 5 6) > > for k in '(7 8 9) > > //do calculation using i, j, and k. The three lists are not > > related. > > end > > end > > end > > > > What is the best way to do this in Chicken? I can use (for-each ...) or > (do > > ...) but it seems neither is straightforward. > > Without knowing the purpose of this it's hard to say. However scheme > is flexible enough to allow an almost verbatim translation using > foof-loop: > > (use foof-loop) > > (loop ((for i (in-list '(1 2 3)))) > (loop ((for j (in-list '(4 5 6)))) > (loop ((for k (in-list '(7 8 9)))) > (print "Magic " i "+" j "+" k " = " (+ > i j k))))) > > HTH, > > Christian > > -- > May you be peaceful, may you live in safety, may you be free from > suffering, and may you live with ease. >
_______________________________________________ Chicken-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-users
