How To Do OpenSCAD Stack-Like Operations? -
I'm very new to OpenCAD, but it's got the most down below. However, I'm not sure how I can perform a stack-like operation. It really does not matter how the data structure is used, as long as I can push and pop the numbers is it possible?
I worked extensively with the pile while applying.
The size of the trick is to use the nested correct associative lists of 2 = eg if you want to push in some stacks:
function push (stack, item) = "Foo", ["Bar", []]]. [item, stack];
If you want to pop the stack:
function pop (stack) = stack [1];
And if you want to undo the value that was popped up:
function peak = stack [0];
You can also apply a map / under work using recursion:
function map (stack) = push (map (pop (stack) ), F (peek (stack))); Reduce function (stack) = f (peak (stack))? Push (stack), f (peak (stack)): reduce (pop (stack));
Of course, this version is now 2015.03, you can list Think of the use of understanding, suppose what you really want.
Comments
Post a Comment