[OpenSCAD] for loop in a function
nate-openscadforum at pedantic.org
Tue Apr 10 20:32:34 EDT 2018
> function sumv(v,i,s=0) = (i==s ? v[i] : v[i] + sumv(v,i-1,s));Depending on
the application, you might want something like:
function sumv(list,start,end) = start>=end? 0 :
so that it terminates on bad input. Of course that version doesn't take
advantage of the overloading on + the way that the one above does.
Sent from: http://forum.openscad.org/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Discuss