[OpenSCAD] recursion limit on concat()

Ronaldo Persiano rcmpersiano at gmail.com
Mon Oct 14 15:50:48 EDT 2019


> Ronaldo, sadly, that code throws the same error on version 2019-05
>

That is surprising! Anyway, as another alternative, you may express your
function iteractively instead:

function points_from_string(s,step=1,angle=90,pos=[0,0,0],dir=0) =
  [for( i  = 0,
        ps = [pos];

        i <= len(s);

        c   = s[i],
        pos = c=="F" ||c=="A" || c=="B"
               ? pos + step*[cos(dir), sin(dir)]
               : pos,
        dir = c=="+"
              ? dir + angle
              : c=="-"
                ? dir - angle
                : dir,
        ps  = concat([pos], ps),
        i   = i+1 )
      if(i==len(s)) each ps ];

s = "FA+BA-FB";
echo(string_to_points(s));
echo(points_from_string(s));
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20191014/b8803283/attachment.html>


More information about the Discuss mailing list