Studio 3
Studio Worksheets
More fractals 🔶
vert_fractal
Refer to slide 22 for examples of what this function should do.
function vert_fractal(rune, n) {
// YOUR SOLUTION HERE
}
// Examples
vert_fractal(heart, 1);
vert_fractal(heart, 5);
Answers
This is approach is similar to the fractal
function seen in the Rune Reading mission! Instead of going left to right, here we are doing it bottom up.
function vert_fractal {
return n === 1
? rune
: stack(vert_fractal(n-1, beside(rune, rune)), rune);
}
corner_fractal
Refer to slide 23 for examples of what this function should do.
function corner_fractal(rune, n) {
// YOUR SOLUTION HERE
}
// Examples
corner_fractal(heart, 1);
corner_fractal(heart, 5);
Answers
Notice how we can reuse both the fractal
and vert_fractal
functions to create this new function!
function corner_fractal {
return n === 1
? rune
: beside(vert_fractal(n, rune),
stack(corner_fractal(n - 1, rune),
fractal(n - 1, stack(rune, rune))));
}