MichaelAtOz wrote
function r2v(r,index=undef) =
(index==undef)
? r2v(r,r[0],dir=(r[0]<=r[2]) )
: (dir && index>r[2]) || (!dir && index<r[2])
? []
: concat([index],r2v(r,index+r[1],dir=dir));
Hmm how about just
function range2vector(r) = [ for (i=r) i];
No recursion needed, seems to work just fine. It's been in my privately
kept stdlib.scad for a while... Not that's I've found much use of it.
Ranges are peculiar indeed, but I've found little practical purpose to
manipulate ranges, other than in a for loop.
--
View this message in context: http://forum.openscad.org/ranges-to-vectors-tp7651p14404.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
ctchin wrote
MichaelAtOz wrote
function r2v(r,index=undef) =
(index==undef)
? r2v(r,r[0],dir=(r[0]<=r[2]) )
: (dir && index>r[2]) || (!dir && index<r[2])
? []
: concat([index],r2v(r,index+r[1],dir=dir));
Hmm how about just
function range2vector(r) = [ for (i=r) i];
No recursion needed, seems to work just fine. It's been in my privately
kept stdlib.scad for a while... Not that's I've found much use of it.
Ranges are peculiar indeed, but I've found little practical purpose to
manipulate ranges, other than in a for loop.
That was written prior to the release of List Comprehensions...
Newly minted Admin - PM me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
View this message in context: http://forum.openscad.org/ranges-to-vectors-tp7651p14421.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Oh... sorry didn't pay attention to the original post date...
--
View this message in context: http://forum.openscad.org/ranges-to-vectors-tp7651p14428.html
Sent from the OpenSCAD mailing list archive at Nabble.com.