The (improved) version of the second code example is:
const transform = [
(shape) => scale(shape, 0.5),
(shape) => rotate(shape, -5),
(shape) => skew(shape, 0.1), ]
let square = new Square(10)
for (let cmd of transform) {
[ status, shape ] = cmd(shape)
if (status != "ok") {
shape = undefined
break
}
}
if(shape)
display(shape)
However, the variable shape isn’t actually used in the for loop.
Shouldn’t that be let shape = new Square(10)?