Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9300227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:44:10+00:00 2026-06-18T22:44:10+00:00

(define-struct restaurant (name address lod)) (define-struct dish (name main-ingredient price)) (define lod (list (make-dish

  • 0
(define-struct restaurant (name address  lod))
(define-struct dish  (name main-ingredient price))

(define lod
  (list
   (make-dish "BNC" "pepper" 15.00)
   (make-dish  "BBQ" "sauce" 20.00)
   (make-dish "BAW" "vanilla" 18.00)
    (make-dish "ACA" "tomato" 15.00)
   (make-dish  "NAM" "onions" 25.00)
   (make-dish "PLA" "milk" 34.00)))

(define lod1
  (list
   (make-dish "AHSH" "carrots" 23.00)
   (make-dish  "PROA" "garlic" 21.00)
   (make-dish "MENE" "eggs" 16.00)
    (make-dish "SAYB" "water" 11.00)
   (make-dish  "WAFA" "chicken" 22.00)
   (make-dish "LDAFK" "chocolate" 10.00)))


(define Sky-Dragon (make-restaurant "Sky Dragon" "23 Cutoiut, NY"  lod))
(define Tomas (make-restaurant "Tomas" "34 Rossi, CA" lod1))


(define restaurant1 Sky-Dragon)
(define restaurant2 Tomas)

I would like to know how would you write a function that consumes a restaurant and produces the total number of dishes the restaurant has. Like I take restaurant1, I get 6 dishes. Hope I am doing this right.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T22:44:11+00:00Added an answer on June 18, 2026 at 10:44 pm

    It’s simple, just use the accessor procedure to retrieve the list of dishes of a restaurant, and then the built-in procedure to determine the size (or “length”) of that list:

    (define (number-of-dishes restaurant)
      (<???>                  ; how do we determine the size of a list?
        (<???> restaurant)))  ; how do we access a restaurant's list of dishes?
    

    I’ll let you figure out the details, but remember – whenever you define a new struct using define-struct, an accessor procedure is automatically created for each of its fields. For example, the price of a dish is obtained by calling dish-price on a dish: (dish-price dish).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Scheme, I can use define-struct to make a binary search tree, but how
I have this struct: #define sbuffer 128 #define xbuffer 1024 typedef struct{ char name[sbuffer];
(define-struct student (first last major age)) (define student1 (make-student David Smith 'Math 19)) (define
(define-struct animal (name species age breakfast-hour dinner-hour)) (define-struct attendant (name a1 a2 a3)) (define
(define-struct student (first last major)) (define student1 (make-student John Smith 'CS)) (define student2 (make-studentJane
I'm using a struct like this: define struct _Fragment{ int a; char *seq; }Fragment;
struct { char a; int b; } x; Why would one define a struct
#define MAX 100 struct bs{ int ab; int ac; }be; struct s{ be b;
I have this struct; #define BUFSIZE 10 struct shared_data { pthread_mutex_t th_mutex_queue; int count;
Is it valid C to declare a struct and define values enclosed in {}?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.