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 6745409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:12:04+00:00 2026-05-26T12:12:04+00:00

Programming language: DrRacket/scheme Hey guys, I am preparing for my first comp sci midterm,

  • 0

Programming language: DrRacket/scheme

Hey guys,

I am preparing for my first comp sci midterm, and have two quick questions that I’d love to get some input on:

(1) What exactly is the difference between a data definition and a
structure definition?

I know that for a data definition, I can have something like:

;; a student is a 
;; - (make-student ln id height gradyear), where 
;; - ln is last name, and
;; - id is ID number, and
;; - height is height in inches, and
;; -gradyear is graduation year

but what is a structure definition?

(2) What exactly are the alphas and betas in contracts that come before functions, i.e.

take : num α-list -> α-list

Thank you in advance!

  • 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-05-26T12:12:04+00:00Added an answer on May 26, 2026 at 12:12 pm

    Quote from How to Design Programs (HtDP):

    A DATA DEFINITION states, in a mixture of English and Scheme, how we
    intend to use a class of structures and how we construct elements of
    this class of data.

    Given a problem to solve you as a programmer must decide how your input data is represented as values. In order for others to understand your program it is important to document how this is done in detail.

    Some input data are simple and can be represented by a single number (e.g. temperature, pressure, etc).

    Other types of data can be represented as fixed number of numbers/strings. (e.g. a cd can be represented as an author name (string), a title (string) and a price (number)). To pack a fixed number of values as one value one can represent this a structure.

    If one needs to represent an unknown number of something, say cds, then one must use a list.

    The data definition is simply your description of how the data are represented in your program.

    To explain what a structure definition is, I’ll quote from HtDP:

    A STRUCTURE DEFINITION is, as the term says, a new form of definition.
    Here >is DrScheme’s definition of posn:

    (define-struct posn (x y))
    

    Let us look at the cd example again. Since there are no builtin “cd values” in Racket, one must define what a cd value is. This is done with a structure definition:

    (define-struct cd (author title price))
    

    After the definition is made one can use make-cd to construct cd values.
    In order to explain that autor and title are expected to be strings, and price is expected to be a number, you must write down a data definition that explains how make-cd is supposed to be used.

    I forgot to answer your second question:

    (2) What exactly are the alphas and betas in contracts that come
    before functions, i.e.

    take : num α-list -> α-list

    The alpha is supposed to be replaced with a type.

    If take get a integer-list (list of integers as input) then the output is an integer-list.

    If take get a string-list (list of strings as input) then the output is an string-list.

    In short if take gets a list of values with some type (alpha) as input, then the output is a list of values with the same type (alsp alpha).

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

Sidebar

Related Questions

Where X is any programming language (C#, Javascript, Lisp, Perl, Ruby, Scheme, etc) which
C++ was the first programming language I really got into, but the majority of
Every programming language I have ever seen has been based on the Latin alphabet,
Which programming language is it easier to support developers in (namely developers that have
I'm using DrRacket for Scheme Programming. for I'm not a person who use native
I have a vague memory of a programming language where 1..10 meant the range
C programming language is known as a zero index array language. The first item
PHP is my first programming language. I can't quite wrap my head around when
Seeking programming language. Must have the following qualities (in order of ascending length of
My first programming language learned was Actionscript, and I'm having a hard time understanding

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.