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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:18:38+00:00 2026-05-26T18:18:38+00:00

I kinda understand how to convert elementary functions such as arithmetics to continuation-passing style

  • 0

I kinda understand how to convert elementary functions such as arithmetics to continuation-passing style in Scheme.
But what if the function involves recursion?
For example,

(define funname 
     (lambda (arg0 arg1)
                (and (some procedure)
                      (funname (- arg0 1) arg1))))

Please give me advices.
Thank you in advance.

  • 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-26T18:18:39+00:00Added an answer on May 26, 2026 at 6:18 pm
    (define (func x y k)
      (some-procedure
       (lambda (ret)
         (if ret
             (- x 1
                (lambda (ret)
                  (func ret y k)))
             (k #f))))
    

    You are lacking a base case, which is why the only explicit call to the continuation is (k #f). If you have a base case, then you’d pass the base case return value to the continuation, also. For example:

    (define (func x y k)
      (zero? x
             (lambda (ret)
               (if ret
                   (k y)
                   (some-procedure
                    (lambda (ret)
                      (if ret
                          (- x 1
                             (lambda (ret)
                               (func ret y k)))
                          (k #f))))))))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand a derived tables I kinda have an idea but
Kinda long title, but anyways... I've been looking at these examples, specifically on the
Kinda hard to explain, but i'll try. I have a datalist that is populated
I understand that the setTimeout function spawns a separate thread that waits for x
I would like to understand how to convert basic C/C++ loops to a CUDA
OK so I'm kinda new to databases in general. I understand the basic theory
My question might be kinda confusing but I'll try my best to explain it.
this is kinda tricky to explain,but here goes....I have multiple hidden divs that swap
Seems begineer but i really do not understand what these lines of code saying,
I'm kinda new to data binding and obviously don't really understand it. I'm trying

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.