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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started