30 lines
764 B
Racket
30 lines
764 B
Racket
#lang slideshow
|
|
|
|
(define one 1)
|
|
(define c (circle 10))
|
|
(define r (rectangle 10 20))
|
|
|
|
(define (square n)
|
|
; A filled square of side n
|
|
(filled-rectangle n n))
|
|
|
|
(define (two-by-two p)
|
|
; hc-append stacks p one after the other by default
|
|
; vc-append does the same thing, but vertically
|
|
(define twice-hori
|
|
(hc-append p p))
|
|
; Here we used twice-hori as an intermediate value
|
|
; Often, a let expression is more convenient
|
|
(vc-append twice-hori twice-hori))
|
|
|
|
(define (checker a b)
|
|
; With let, we can define multiple names at once
|
|
(let ([ab (hc-append a b)]
|
|
[ba (hc-append b a)])
|
|
(let ([top (colorize ab "red")]
|
|
[bott (colorize ba "green")])
|
|
(vc-append top bott))))
|
|
|
|
(define checker-board
|
|
(checker (square 10) (square 10)))
|