|
|
Mathuin wrote:
> I don't think assignments, comparisons, or statements can be passed as macro
> arguments, but if they could be, something like this would almost work:
>
> #macro for(init, check, inc, body)
well, in case somebody loves odd syntactic constructs, here
is a somewhat silly macro for a counter-based loop, although
in this form not nestable for multiple loops:
#macro FROM_TO(FROM,TO)
#local i = FROM;
#while (i < TO)
FOR(i)
#declare i = i + 1;
#end
#end
Ponder it for a while and scroll down if confused ;)
...
Scroll some more
...
// Here is how to actually write a loop with it:
#macro FOR(I)
sphere {<I,0,0>,1 pigment {color rgb 1}}
#end FROM_TO(0,10)
... and what a good thing that macros can be redefined ;)
Post a reply to this message
|
|