[OpenSCAD] Functions literals / higher order functions
rudolf at digitaldocument.de
Sun Nov 3 17:46:59 EST 2019
Yes! Just try it out.
function foo(a, f) = f(a);
gives obviously a syntax error: "Ignoring unknown variable 'sin' ... "
while the following code does what you intended.
echo(foo(30, function(x) sin(x)));
Trying to redefine sin() by
sin = function(x) sin(x);
in order to call
will detect a recursion. While the following typo will indeed brick OpenSCAD
sin = function(x) sin();
Sent from: http://forum.openscad.org/
More information about the Discuss