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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:05:37+00:00 2026-06-01T02:05:37+00:00

This is a homework question. Question My attempt (the whole file): http://pastebin.com/TS6mByEj If you

  • 0

This is a homework question.

Question
enter image description here

My attempt (the whole file): http://pastebin.com/TS6mByEj

If you search let var = exp1 in body, that’s the function I need to extend according to the question.

When I test the sample code above, I get an error apply-env: No binding for y

(eval “let x = 30
in let x = -(x,1)
y = -(x,2)
in -(x,y)”)

; The following is execution log

The-next-two-lines-shows-var-and-exp1
(x)
(#(struct:const-exp 30))

diff-exp
#(struct:var-exp x)
#(struct:const-exp 1)

diff-exp
#(struct:var-exp x)
#(struct:const-exp 2)

The-next-two-lines-shows-var-and-exp1
(x y)
(#(struct:diff-exp #(struct:var-exp x) #(struct:const-exp 1)) #(struct:diff-exp #(struct:var-exp x) #(struct:const-exp 2)))

diff-exp
#(struct:var-exp x)
#(struct:var-exp y)

I know this is really long language, but if anyone can kindly lead me to the right direction would be really really nice.

Thank you!


UPDATE

Right before I evaluate and hit the error, the new environment env1 is like this

(#(struct:extend-env x #(struct:num-val 29) #(struct:extend-env x #(struct:num-val 30) #(struct:extend-env i #(struct:num-val 1) #(struct:extend-env v #(struct:num-val 5) #(struct:extend-env x #(struct:num-val 10) #(struct:empty-env))))))

#(struct:extend-env y #(struct:num-val 28) #(struct:extend-env x #(struct:num-val 30) #(struct:extend-env i #(struct:num-val 1) #(struct:extend-env v #(struct:num-val 5) #(struct:extend-env x #(struct:num-val 10) #(struct:empty-env)))))))

One of them is #(struct:extend-env y #(struct:num-val 28). So y exists in the environment which it is going to be evaluated, except it is not part of the car env1. It is in cdr env1

Yet, my code relies on car env1….

  • 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-01T02:05:38+00:00Added an answer on June 1, 2026 at 2:05 am

    You’ve got your finger on the problem, but your language suggests some conceptual problems. In particular, env1 is not an environment, it’s a list of environments. Why are you using map? What are you taking the car of the result? What happens if you run your interpreter on "let in 5" (ie, no variable bindings)?

    Your use of map and car suggests to me that you’re attempting to code on autopilot (“I have a list… map does stuff with lists!”). Either that or you’re thinking that extend-env changes (mutates) the environment and map is a way of mutating it several times. But that’s wrong.

    My advice: think about what you want the environment to contain. Make a separate helper function for computing the new environment. Make it a simple recursive function: no higher-order helpers like map (yet). Write test cases for it. Once you get it working (ie, tested), see if it fits a pattern that you can use a higher-order function to simplify.

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

Sidebar

Related Questions

This is a homework question,I'm trying to do a Depth-first search function in Scheme,Here's
This is a homework question, binary search has already been introduced: Given two arrays,
I'm trying to solve this problem, its not a homework question, its just code
Disclaimer: This is for a homework assignment, but the question is not regarding the
This is an attempt to rewrite some old homework using STL algorithms instead of
I've been thinking about this homework question for a bit now. Given an number
I'm stuck with this Java homework question: Write a new method, Refund, that simulates
This is a homework question, exactly as follows: The heuristic path algorithm (Pohl, 1977)
This is a homework question. Frankly, I'm not sure how a C program delivers
This IS NOT a Homework question! While building my current student database project I

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.