Question: Using DrRacket programming language: Lets build some lego buildings out of lego bricks. Here are data definitions for lego bricks and lego buildings: (define-struct lego

Using DrRacket programming language:

Lets build some lego buildings out of lego bricks. Here are data definitions for lego bricks and lego buildings:

(define-struct lego (label color width))

;; A Lego is a structure:

;; (make-lego Number Symbol Number)

;; interpretation: (make-lego l c w) is the lego brick

;; with label l, color c, and width w (in pixels).

(define-struct bigger (lego left right))

;; A LegoBldg (lego building) is one of:

;; - Lego

;; - (make-bigger Lego LegoBldg LegoBldg)

;; interpretation: (make-bigger lg lft rgt) makes a bigger

;; lego building by putting a lego brick lg on top of two lego

;; buildings lft (left) and rgt (right).

Problem 1 Design a function, count-bricks, that takes a lego building and produces the total number of lego bricks in that building.

Problem 2 Each lego brick is 10 pixels tall. Design a function, how-high, that takes a lego building and produces the total height of the lego building (in pixels).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!