How am I supposed to create rows and columns of images?

First, I'm going through HtDP 2nd Edition and am using the BSL language pack.

I'm currently on Exercise 131 and this is what it says:

Exercise 131: Design two functions: col and row.

The function col consumes a natural number n and an image i. It produces a column—a vertical arrangement—of n copies of i.

The function row consumes a natural number n and an image i. It produces a row—a horizontal arrangement—of n copies of i

Use the two functions to create a rectangle of 8 by 18 squares, each of which has size 10 by 10.

I'm looking at place-image, besides, above and nothing stands out on how to do this. These functions don't take a list of images but individual images. EX: (besides rect1 rect2 rect3) as opposed to (besides (list rect1 rect2 rect3)). Plus if I go by how the functions are defined it seems like I'll have overlap on the images, since the functions themselves are independent. Basically the overlap I'm talking about is on the first image of each row.

I'm not looking for the answer (though I'll take it if you got it), but a hint, sign, divine intervention in the right direction.


  • Here is an example to get you going:

    ; images->row : list-of-images -> image
    (define (row->image row)
         [(empty? row) empty-image]
         [else         (beside (first row) 
                               (row->image (rest row)))]))
    (row->image (list (square 20 "solid" "red")
                      (square 20 "solid" "blue")
                      (square 20 "solid" "green")))