[OpenSCAD] recursion limit on concat()

Ronaldo Persiano rcmpersiano at gmail.com
Mon Oct 14 09:37:28 EDT 2019


On, 14.10.2019, 13:59, kitwallace <kit.wallace at gmail.com> wrote:

> Anyone able to suggest a work-around?
>

With the let() clauses of your code, no tail recursion elimination will be
done by older OpenSCAD versions.
An alternative to Torsten Paul's suggestion is to eliminate the let()
clauses from your code.
Something like:

function string_to_points(s,step=1,angle=90,pos=[0,0,0],dir=0,i=0,ps=[]) =
    i == len(s)
      ? concat([pos],ps)
      : string_to_points(s,
                         step,
                         angle,
                         s[i]=="F" ||s[i]=="A" || s[i]=="B" // newpos
                           ? pos + step*[cos(dir), sin(dir)]
                           : pos,
                         s[i]=="+"                          // newdir
                           ? dir + angle
                           : s[i]=="-"
                              ? dir - angle
                              : dir,
                        i+1,
                        concat([pos],ps) )
     ;


I haven't tested this code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20191014/124511f3/attachment.html>


More information about the Discuss mailing list