[OpenSCAD] Incrementing a variable doesn't work as expected.
nop.head at gmail.com
Wed Apr 1 04:32:03 EDT 2015
You can't modify variables, so not only is inc out of scope but you can't
change the value of pos.
Recursion is the right way to do it but you have infinite recursion because
you unconditionally call cpos(s,n-1).
On 1 April 2015 at 08:44, nigeljohnson73 <nigel at nigeljohnson.net> wrote:
> For info, here is my recursive position counter that fails:
> function cpos(s, n) = cpos(s,n-1) + (n == -1) ? (0) : ( (s[n]==".") ? 2 :
> when I use it instead of pos in the x coordinate for example in the dit:
> translate([cpos(s,i)+lu/2,0,0]) cylinder(r=lu/2, h = (id+wt+2)/2);
> it says recursion detected. It's not lying but the manual says I can do
> recursion with the trigraph stuff.
> View this message in context:
> Sent from the OpenSCAD mailing list archive at Nabble.com.
> OpenSCAD mailing list
> Discuss at lists.openscad.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Discuss