Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Last active November 2, 2019 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/bb297b69b8c053709d647df65a8f2b5f to your computer and use it in GitHub Desktop.
Save chelseatroy/bb297b69b8c053709d647df65a8f2b5f to your computer and use it in GitHub Desktop.
Bob Box
#lang racket
(define (make-bob-box x y w h)
'bob-box (cons (cons x y) (cons w h)))
(define (bob-width box)
(car (cdr (box))))
(define (bob-height box)
(cdr (cdr (box))))
(define b (make-bob-box 1 2 3 4))
(define (bob-area box)
(* (bob-width box) (bob-height box)))
(define b (make-bob-box 1 2 3 4))
(bob-area b) ;--> 12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment