This is my notepad where i collect the useful snippets of OpenSCAD code that i use over and over. Some better curated than others, some formatted for clarity some for efficiency.
Thursday, May 11, 2017
Sum all elements of a list
Recursively sums all elements of a list Usage:
My_sum1=addl( [ 12, 3, 4, 62, 9 ]);
My_sum2=addl( [ [x,y,z], [x,y,z], [x,y,z], [x,y,z]]);
function addl(list, c = 0) =
c < len(list) - 1 ?
list[c] + addl(list, c + 1)
:
list[c];
No comments:
Post a Comment