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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:57:20+00:00 2026-06-11T15:57:20+00:00

I’d like to ask if you can help me with a programming exercise. I’m

  • 0

I’d like to ask if you can help me with a programming exercise. I’m trying to make a lambda expression of this form:

λz.x(yz)

The way I understand this, is that y is a function, applied to the value z. Then x is a function applied to what comes out if the function y is applied to z. The whole expression then says this:

λz.x(yz) means: Do the following with the argument z:
  1. Apply the function y to z.
  2. Apply the function x to what comes out of the first procedure.

I’ve made this program to try to get Scheme to do all of the above:

(define (zlamb)
  (lambda (z)
    (lambda (x)
      (* (lambda (y) (* z 4)) 2))))

When I run it, all I get is this:

Welcome to DrRacket, version 5.3 [3m].
Language: R5RS; memory limit: 128 MB.
( (zlamb) 3)
procedure:...lambdaefing1.rkt:3:4
>

Can anybody please explain to me what I’m doing wrong? What I wanted to get is (3 * 4) * 2 = 24. So I made (or thought I made) the inner function y = z * 4 and the outer function x = y(z) * 2.

I’ve searched all over the internet for explanations, but can’t find the particular needle I’m looking for in the haystack.

  • 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-11T15:57:21+00:00Added an answer on June 11, 2026 at 3:57 pm

    Let’s break your program down from the inside out:

    (* z 4)
    

    Multiply z by 4

    (lambda (y) (* z 4))
    

    A function returning z*4

    (* (lambda (y) (* z 4)) 2)
    

    The product of that function and 2. You cannot multiply a function by 2.
    This is likely what is causing your bug; perhaps you mean to do the following:

    (define (zlamb)
      (lambda (z)
        ((lambda (y) (* 2 (y z))) ; Note the two parenthesis before lambda - this is a function application
          (lambda (z2) (* z2 4)))))
    

    Firstly note that both zs end up being the same, since z2 is bound to the value of the z in line 3. They could in fact both be named z but I named them differently to prevent confusion.

    It further appears that your basic problem is in confusing the name of a function with its arguments:

    (lambda (name) ...)
    

    creates an anonymous function with an argument of name. The reason we are able to refer to the anonymous function in line 4 as y in line 3 is by making the construction

    ((lambda (y) ...) (lambda ...))
    

    which passes the second function as an argument to the first, thus naming it y.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has

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.