1

まず、HtDP 2nd Editionを使用しており、BSL言語パックを使用しています。

私は現在、エクササイズ 131を行っています。

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.

その上、上にある場所の画像を見ていますが、これを行う方法について目立ったものはありません。これらの関数は、画像のリストではなく、個々の画像を受け取ります。例: (besides (list rect1 rect2 rect3)) とは対照的に (besides rect1 rect2 rect3)。さらに、関数の定義方法を見ると、関数自体が独立しているため、画像が重複しているように見えます。基本的に、私が話している重複は、各行の最初の画像にあります。

私は答えを探しているわけではありません (ただし、あなたが見つけた場合はそれを受け取ります) が、ヒント、サイン、正しい方向への神の介入.

4

1 に答える 1

3

以下に例を示します。

; images->row : list-of-images -> image
(define (row->image row)
  (cond
     [(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")))
于 2013-02-23T18:42:18.210 に答える