[OpenSCAD] OpenSCAD Digest, Vol 23, Issue 11

Whosawhatsis whosawhatsis at gmail.com
Sun Oct 23 20:06:19 CEST 2011


Are you sure that the ternary operator exists in OpenSCAD? I've tried to use it several times and it has never worked, forcing me to write a significantly longer script to code around it. I've never used a function in OpenSCAD (only modules), but if it doesn't work in functions, perhaps there are other situations where it would be very useful but doesn't work.


On Sunday, October 23, 2011 at 10:48 AM, nop head wrote:

> It appears that you can have recursions because if a function calls itself openscad crashes. But for some reason the ternary operator seems to not work on functions. Is that just a bug or is there a fundamental reason why it doesn't?
> 
> If it did you could solve the problem with
> 
> function toto(k) = k ? toto(k-1) + k : 0;
> 
> On 23 October 2011 17:47, William Adams <william_a_adams at msn.com (mailto:william_a_adams at msn.com)> wrote:
> >  But of course RapCAD can do this!
> >  
> > It sure would be useful if functions could have bodies, and recursion.  But, plenty can be done without it.
> >  
> > You just have to leave typical notions of programming behind, and just do your loops as part of a module, where instead of returning a result, you code up an object directly.
> >  
> > Another way OpenScad could be extended is if the child() module could give you access to the various attributes of an object.  In particular the points mesh.  Then I could stuff anything into the points mesh, and read it somewhere else.  This is similar to what GLSL did in the early days where 'texture' was just another name for 'random memory'.
> >  
> > -- William
> > 
> > ===============================
> >  - Shaping clay is easier than digging it out of the ground.
> > 
> > http://blog.nanotechstyles.com
> > http://www.thingiverse.com/WilliamAAdams
> > https://github.com/Wiladams
> >  
> > 
> >  
> > Date: Sun, 23 Oct 2011 16:55:36 +0100
> > From: nop.head at gmail.com (mailto:nop.head at gmail.com)
> > To: openscad at rocklinux.org (mailto:openscad at rocklinux.org)
> >  Subject: Re: [OpenSCAD] OpenSCAD Digest, Vol 23, Issue 11
> > 
> > 
> > Surely it's an AP:
> >  
> > function toto(k) = (k+1) * k / 2;
> > 
> > But that steps round the issue that there are no loops inside functions.
> > 
> > On 23 October 2011 16:46, Giles Bathgate <giles.bathgate at gmail.com (mailto:giles.bathgate at gmail.com)> wrote:
> > > > function toto(k) { return k + 1; }
> > > 
> > > Syntax error you want:
> > > 
> > >  function toto(k) = k+1;
> > > 
> > >  Regards
> > > 
> > >  Giles
> > > _______________________________________________
> > >  OpenSCAD mailing list
> > > OpenSCAD at rocklinux.org (mailto:OpenSCAD at rocklinux.org)
> > > http://rocklinux.net/mailman/listinfo/openscad
> > 
> > 
> > _______________________________________________ OpenSCAD mailing list OpenSCAD at rocklinux.org (mailto:OpenSCAD at rocklinux.org) http://rocklinux.net/mailman/listinfo/openscad 
> > _______________________________________________
> >  OpenSCAD mailing list
> > OpenSCAD at rocklinux.org (mailto:OpenSCAD at rocklinux.org)
> > http://rocklinux.net/mailman/listinfo/openscad
> > 
> 
> _______________________________________________
> OpenSCAD mailing list
> OpenSCAD at rocklinux.org (mailto:OpenSCAD at rocklinux.org)
> http://rocklinux.net/mailman/listinfo/openscad

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rocklinux.net/pipermail/openscad/attachments/20111023/f0fb0def/attachment-0001.html


More information about the OpenSCAD mailing list