[OpenSCAD] Functions literals / higher order functions

Ronaldo Persiano rcmpersiano at gmail.com
Tue Nov 26 06:58:12 EST 2019

Yet another hack that works:

function move(a, g) =
     let( v = g(x+a) ) v;

g1 = function(x) x;
g2 = move(2, g1);
g3 = move(3, g2);


Compiling design (CSG Tree generation)...

ECHO: g3_x = function(x) let(v = g((x + a))) v

ECHO: g3_2 = 7

Compiling design (CSG Products generation)...

Geometries in cache: 1

Geometry cache size in bytes: 270008

CGAL Polyhedrons in cache: 0

CGAL cache size in bytes: 0

Compiling design (CSG Products normalization)...

Normalized CSG tree has 0 elements
Compile and preview finished.

I can't see how scope may matter here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20191126/5a79aa38/attachment.html>

More information about the Discuss mailing list