22a. More Recursion
-
vblock
: number(n) image(img) -> image. Makes a vertical stack ofn
copies ofimg
. -
sum-cubes
: number(n) -> number. Finds the sum of the firstn
perfect cubes. The first perfect cube is 1x1x1=1. The second perfect cube is 2x2x2 = 8. Etc. -
hblock
: number(n) image(img) -> image. Make a horizontal stack ofn
copies ofimg
. -
grid
: number(rows) number(columns) image -> image. Make a grid that iscolumns
wide androws
tall of the image repeated. -
add-sqrt
: number(start) number(end) -> number. Add up(sqrt n)
for every integern
withstart <= n <= end
If no numbers fit this description, the sum should be zero.Example: when start=4 and end=5, the answer is
(+ (sqrt 4) (sqrt 5))
, which is about 4.236.(check-expect (add-sqrt 4 3) 0) (check-expect (add-sqrt 4 4) 2) (check-within (add-sqrt 4 5) 4.23 0.01) (check-within (add-sqrt 4 8) 12.15 0.01)
-
lots-of-hyphens
: string(word) -> string. Insert a hyphen after every letter in the word.(lots-of-hyphens "grape") ==> "g-r-a-p-e-"
Extra: get
"g-r-a-p-e"
instead. -
ten-circle
: number(start) number(end) -> image. Produces concentric circles starting at radiusstart
and drawing every 10 units until the radius is at leastend
. Assumestart < end
.