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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:51:27+00:00 2026-05-21T15:51:27+00:00

I saw that a similar question was asked before, but I don’t understand another

  • 0

I saw that a similar question was asked before, but I don’t understand another issue here.

Here are two functions:

(define x 2)
(define a 2)

(define goo
  (lambda (x)
    (display x)
    (lambda (y) (/ x y))))

(define foo
  (let ((f (goo a)))
    (lambda (x)
      (if (= x 0)
          x
          (f x)))))

What is the return value of (foo (foo 0))? What will print out to the screen?

As I understand it, when I run (foo 0) in the beginning, 2 will print out (we will enter the function goo), and the return value will be 0. Then, we will enter the function foo again with (foo (foo 0)) => (foo 0). We again enter the function goo and 2 will print out. But when I run it, 2 is printed just once. I think I’m missing a critical issue about let and its connection to lambda.

  • 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-21T15:51:28+00:00Added an answer on May 21, 2026 at 3:51 pm

    The let inside the definition of foo, and therefore the application of goo to a, is evaluated when foo is defined, not when foo is evaluated.

    Look at it this way: what is the value of foo? It is the lambda expression. The binding of f is closed over by foo, it is not “redone” every time foo is evaluated.

    Edit: here’s an example without lambdas

    > (let ((x (sqrt 2))) (* x 3))
    4.24264068711929
    > (define bar (let ((x (sqrt 2))) (* x 3)))
    > bar
    4.24264068711929
    >        
    

    When you evaluate bar you are not calling sqrt again. bar is defined as the body of the let, in this case a number that is the result if an expression.

    In your example the body of the let is a lambda expression. But just like my example, the let binding is not re-executed.

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

Sidebar

Related Questions

I saw that there are many similar question being asked. But in my case,
I know that some similar questions has been asked here, but I saw all
I saw this similar question here but can't figure out how to use Contains
I saw a question that is similar to my one but not the same,
I saw a similar question which asked how to monitor the progress of a
I saw similar question here in SO, where someone wants to do the same
I saw this answer to a similar question , but it always scares me
I saw some other similar questions on this topic here but they were not
I don't know if this has been asked here. I saw couple of questions
I saw there are similar question to this. But I couldn't find an answer.

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.