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

  • SEARCH
  • Home
  • 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 9202109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:10:43+00:00 2026-06-17T23:10:43+00:00

(define-struct student (first last major age)) (define student1 (make-student David Smith ‘Math 19)) (define

  • 0
(define-struct student (first last major age))

(define student1 (make-student "David" "Smith" 'Math 19))
(define student2 (make-student"Joe" "Jones" 'Math 21))
(define student3 (make-student "Eli" "Black" 'Spanish 20))

(define (same-age? s1 s2)
  (string=? (student-age s1)
            (student-age s2)))

so I am trying to get a boolean as an output if two students are the same age, but when I run it, it says it expects a string as the 1st argument, but given 19. What is the problem?

  • 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-17T23:10:44+00:00Added an answer on June 17, 2026 at 11:10 pm

    You create students with their age fields being integers, not strings (note the lack of double-quotation marks), then try to use string=? function to compare them. You should either use the = function to compare on age:

    (define-struct student (first last major age))
    
    (define student1 (make-student "David" "Smith" 'Math 19))
    (define student2 (make-student "Joe" "Jones" 'Math 21))
    (define student3 (make-student "Eli" "Black" 'Spanish 20))
    
    (define (same-age? s1 s2)
      (= (student-age s1)
         (student-age s2)))
    

    or create students with their age fields represented as strings:

    (define-struct student (first last major age))
    
    (define student1 (make-student "David" "Smith" 'Math "19"))
    (define student2 (make-student "Joe" "Jones" 'Math "21"))
    (define student3 (make-student "Eli" "Black" 'Spanish "20"))
    
    (define (same-age? s1 s2)
      (string=? (student-age s1)
                (student-age s2)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(define-struct student (first last major)) (define student1 (make-student John Smith 'CS)) (define student2 (make-studentJane
I want to define a struct in a flex program : %{ #include <math.h>
In Scheme, I can use define-struct to make a binary search tree, but how
(define-struct animal (name species age breakfast-hour dinner-hour)) (define-struct attendant (name a1 a2 a3)) (define
I have this struct for people: (define-struct person ( first ; a string: first
Say I have a struct defined as such struct Student { int age; int
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;

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.