Building Abstractions with Data - Hierarchical Data and the Closure Property - Example: A Picture Language - Transforming and combining painters - flipping horizontally, rotation, 180 degrees, 270 degrees
Structure and Interpretation of Computer Programs: JavaScript Edition(Harold Abelson(著)、Gerald Jay Sussman(著)、Julie Sussman(著)、The MIT Press)のChapter 2(Building Abstractions with Data)、2.2(Hierarchical Data and the Closure Property)、2.2.4(Example: A Picture Language)、Transforming and combining painters、Exercise 2.50の解答を求めてみる。
コード
function flip_horz(painter) {
return transform_painter(
painter,
make_vect(1, 0),
make_vect(0, 0),
make_vect(1, 1)
);
}
function rotate180(painter) {
return transform_painter(
painter,
make_vect(1, 1),
make_vect(0, 1),
make_vect(1, 0)
);
}
function rotate270(painter) {
return transform_painter(
painter,
make_vect(0, 1),
make_vect(0, 0),
make_vect(1, 1)
);
}