Search code examples
arrayslistlist-comprehensionopenscad

How to save the results of a computation happing inside loop with openSCAD?


When I computer something inside a loop, how I can use it later?


Solution

  • You can save results with the help of list comprehensions.

    values = [0, 1, 2, 4, 8, 16];
    result = [ for(i = [0 : len(values) - 1]) [i, values[i]] ];
    echo(result);
    

    Check out the manual for more information.