[OpenSCAD] Functions literals / higher order functions

Ronaldo Persiano rcmpersiano at gmail.com
Mon Nov 25 21:08:51 EST 2019


Michael,

You may need another coffee after confirming that the following runs
without error:

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

g1 = function(x) x;
g2 = move(0,g1);
//g0 = g2;
g0 = function(x) g2(x) ;
g3 = move(0,g0);

echo(g3_x=g3);
echo(g3_2=g3(2));


unless the commented line substitute the g0 definition.

Compiling design (CSG Tree generation)...

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

ECHO: g3_2 = 2

Compiling design (CSG Products generation)...

Geometries in cache: 5

Geometry cache size in bytes: 1774120

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.
Total rendering time: 0 hours, 0 minutes, 0 seconds


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


More information about the Discuss mailing list