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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:52:11+00:00 2026-06-14T12:52:11+00:00

One problem on one of my practice exams is centered around message passing and

  • 0

One problem on one of my practice exams is centered around message passing and data directed program. It asks for a procedure that utilizes the table initializing these install packages:

(define (attach-tag tag data) (cons tag data))
(define (get-tag data) (car data))
(define (get-contents data) (cdr data))

(define (install-metric-package)
; internal procedures
(define (get-kilometers d) d)
(define (get-miles d) (/ d 1.6))
(define (make-from-kilometers d) d)
(define (make-from-miles d) (* d 1.6))
; install metric packages
(2d-put! 'get-kilometers 'metric get-kilometers)
(2d-put! 'get-miles 'metric get-miles)
(2d-put! 'make-from-kilometers 'metric
   (lambda(d) (attach-tag 'metric (make-from-kilometers d))))
(2d-put! 'make-from-miles 'metric
   (lambda(d) (attach-tag 'metric (make-from-miles d))))
'done)

(define (install-english-package)
; internal procedures
(define (get-kilometers d) (* d 1.6))
(define (get-miles d) d)
(define (make-from-kilometers d) (/ d 1.6))
(define (make-from-miles d) d)
; install english packages
(2d-put! 'get-kilometers 'english get-kilometers)
(2d-put! 'get-miles 'english get-miles)
(2d-put! 'make-from-kilometers 'english
   (lambda(d) (attach-tag 'english (make-from-kilometers d))))
(2d-put! 'make-from-miles 'english
   (lambda(d) (attach-tag 'english (make-from-miles d))))
'done)

and allows the generic operators to work. Normally, I would have some code to show effort on my part, but for about a day, I’ve been completely stumped on how to even BEGIN with this one. All I’m given to start with is this:

(define (generic-op operator object)

I do remember having a lab on this, but it was basically taking an already-existing generic procedure and creating simple procedures to get values already contained within it. If anyone can shed some light on how to approach this, I would appreciate it greatly. Again, I’m sorry that I have nothing to show on my part, but I honestly do not know what to do here.

  • 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-14T12:52:12+00:00Added an answer on June 14, 2026 at 12:52 pm

    The 2d-put! procedure is simply adding entries to the table. After you run the install-*-package code you end up with something like this (where [proc] is one of the procedures defined in your given code):

                          | 'metric | 'english |
    'make-from-kilometers | [proc]  |  [proc]  |
    'make-from-miles      | [proc]  |  [proc]  |
    'get-kilometers       | [proc]  |  [proc]  |
    'get-miles            | [proc]  |  [proc]  |
    

    Then you’re going to use 2d-get in the body of generic-op so that whenever you call the procedure on a piece of tagged data your program will know which version (metric/english) of the procedure it should use.

    (define (generic-op operator object)
        ((2d-get [first-tag] [second-tag]) [data]))
    

    In this form the [first-tag] will just be the symbol used to designate the operator, e.g. 'get-miles, the [second-tag] will be the symbol that was attached to the data which you can access with the given procedure get-tag, and [data] is the number that you actually want to do the operation on which you can access with the given procedure get-contents. Assemble all that into a final answer for something like this:

    (define (generic-op operator object)
        ((2d-get operator (get-tag object)) (get-contents object)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im facing one problem in streaming data capture for reading the broadcast data during
I have one problem , I want to get some data from XML file
I'm trying one sample program for practice and i want to display results of
I've worked on projects that have very complex XML configuration, and one problem that's
I am interested, what is best practice to avoid that small problem :) Lets
im doing some practice sql problems one of the questions is: Prepare a shipping
I have one problem with parsing *.docx document with OpenXML (C#). So, here's my
We are facing one problem with DownloadStringCompleted method always returning same result in windows
I have one problem with Javascript Nodes.I want to find out what button was
i have one problem with handling list,i have three class named as UserInf,userData,userProcess,i created

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.