[OpenSCAD] what base language is used in OpenSCAD

Jordan Brown openscad at jordan.maileater.net
Fri Apr 27 20:12:23 EDT 2018


On 4/26/2018 2:51 PM, ken at volksswitch.org wrote:
>
> I’d like to be able to convert a string to an integer in OpenSCAD. 
> For example:
>
>  
>
> string = “11”;
>
> number = xxx(string);
>


Here's what I come up with:

    function atoi1(s, n) = n < 0 ? 0 : atoi1(s, n-1)*10 + search (s[n], "0123456789")[0];
    function atoi(s) = atoi1(s, len(s)-1);
    echo(atoi("123"));

It seems like it could be simplified a bit.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20180427/906bf3b7/attachment.html>


More information about the Discuss mailing list