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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:47:44+00:00 2026-05-20T09:47:44+00:00

I ran into this code on Wikipedia : (define (pyth x y k) (*

  • 0

I ran into this code on Wikipedia:

(define (pyth x y k)
    (* x x (lambda (x2)
        (* y y (lambda (y2)
            (+ x2 y2 (lambda (x2py2)
                (sqrt x2py2 k))))))))

The article says that that code is the Continuation-Passing version of another piece of code:

(define (pyth x y)
    (sqrt (+ (* x x) (* y y))))

However, I’m quite confused: How does that even work? How do you multiply a number by a lambda here? (* x x (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-20T09:47:44+00:00Added an answer on May 20, 2026 at 9:47 am

    In the Wikipedia example, * doesn’t mean the same thing as * in the conventional example.

    I would rewrite the Wikipedia example as:

    (define (pyth x y k)
        (cps-* x x (lambda (x2)
            (cps-* y y (lambda (y2)
                (cps-+ x2 y2 (lambda (x2py2)
                    (cps-sqrt x2py2 k))))))))
    

    In this form, each of the cps-xxx functions perform the operation indicated and then pass the result to the last argument. You could call it like this:

    (pyth 2 3 display)
    

    which would multiply 2 and 3, giving 6, and then passing 6 to display. (Actually you would want to pass the result to a cps-display that displayed its initial argument(s) and then called another function specified as its last parameter).

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

Sidebar

Related Questions

I am trying to convert VB6 code to c# and I ran into this
Trying to understand Ruby a bit better, I ran into this code surfing the
Cheers, I ran into this chunk of code in Programming Game AI by Example:
Has anyone ran into this issue? We have a mobile site that can't use
I ran into this error when building my code with CLANG: In file included
I just ran into this line of code: if( lineDirection.length2() ){...} where length2 returns
I ran into a slight coding problem with WordPress template. This is the code
I ran into this today when unit testing a generic dictionary. System.Collections.Generic.Dictionary<int, string> actual,
Recently I ran into this error in my web application: java.lang.OutOfMemoryError: PermGen space It's
Today, I ran into this weird problem with a user using Mac OS X.

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.