[OpenSCAD] flattening mixed lists of lists
kit.wallace at gmail.com
Mon Apr 13 02:54:07 EDT 2015
The code is here -
faces are constructed in function rrp (line 234) as a nested list and
flattened in fold_render(line 256) using function dflatten()
The context of the code is described in my blog - basically it generates
nets of solids and folds them
On Sun, Apr 12, 2015 at 5:26 PM, doug.moen [via OpenSCAD] <
ml-node+s1091067n12350h42 at n5.nabble.com> wrote:
> Kit, could you show your code that generates the face list?
> I'd like to see it, because I'm considering an extension to list
> comprehensions that would eliminate the need to use 'flatten'
> functions for post processing. I'd like to see if my proposed
> extension works for your code.
> Doug Moen
> On 06/04/2015, kitwallace <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=12350&i=0>> wrote:
> > I'm generating faces as a list of points. However the list of faces
> > comprises a mixture of faces and lists of faces. I need to flatten this
> > mixed list. So far I'm using
> > function depth(a) = len(a)== undef ? 0 :
> > 1+depth(a);function flatten(l) = [ for (a = l) for (b = a) b ]
> > dflatten(l,d=2) =// hack to flatten mixed list and list of lists
> > flatten([for (a = l) depth(a) > d ? [for (b=a) b] : [a]]); l= [
> > [[1,2],[2,3]], [[[1,2],[2,3]]] ];lf = dflatten(l);echo(len(lf),lf);
> > but it doesn't really work generally : d = 1 should yield 4 , not 3
> > really struggled to come up with a correct recursive formulation.
> > --
> > View this message in context:
> > http://forum.openscad.org/flattening-mixed-lists-of-lists-tp12316.html
> > Sent from the OpenSCAD mailing list archive at Nabble.com.
> OpenSCAD mailing list
> [hidden email] <http:///user/SendEmail.jtp?type=node&node=12350&i=1>
> If you reply to this email, your message will be added to the discussion
> To unsubscribe from flattening mixed lists of lists, click here
View this message in context: http://forum.openscad.org/flattening-mixed-lists-of-lists-tp12316p12352.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Discuss