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.
echo( len3( [1,1,2] ) ); echo( len3( [1,1,2] - [0,2,0] ) ); function len3(v) =len(v)>1?
sqrt(addl([for(i=[0:len(v)-1])pow(v[i], 2)]))
:len(v)==1?v[0]:v; function addl(l,c=0)= len(l)-1 >c?l[c]+addl(l,c+1):l[c];