Building Abstractions with Data - Hierarchical Data and the Closure Property - Example: A Picture Language - Levels of language for robust design
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)、Levels of language for robust design、Exercise 2.52の解答を求めてみる。
コード
// b.
function corner_split(painter, n) {
if (n === 0) {
return painter;
}
return beside(
below(
painter,
up_split(painter, n - 1)
),
below(
right_split(painter, n - 1),
corner_split(painter, n - 1)
)
);
}
// c.
function square_limit(painter, n) {
return square_of_four(
flip_horiz,
identity,
rotate180,
flip_vert
)(
corner_split(painter, n)
);
}