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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:02:10+00:00 2026-05-20T05:02:10+00:00

I’m new to programming and have had a hard time understanding recursion. There’s a

  • 0

I’m new to programming and have had a hard time understanding recursion. There’s a problem I’ve been working on but can’t figure out. I really just don’t understand how they are solvable.

“Define a procedure plus that takes two non-negative integers and returns their sum. The only procedures (other than recursive calls to plus) that you may use are: zero?, sub1, and add1.

I know that this is a built in functions in scheme, so I know they’re possible to solve, I just don’t understand how. Recursion is so tricky!

Any help would be greatly appreciated!
=] Thanks

I’m working in Petite Chez Scheme (with the SWL editor)

  • 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-20T05:02:10+00:00Added an answer on May 20, 2026 at 5:02 am

    Recursion is a very important concept in software development. I don’t know (petit chez) scheme so I will approach this from a general angle.

    The concept of a recursive function is to repeat the same task over and over again until you reach some limiting boundary. Taking your first question, you have two numbers and you need to add them together. However, you only have the ability to add 1 to a number or subtract 1 from a number. You also have the literal value zero.

    So. consider you numbers as two buckets. They each have 10 stones in them. You want to “add” those two buckets together. You are only permitted to move one stone at a time (i.e. you can’t grab a handful or tip one bucket into the other).

    Lets say you want to move everything from the left bucket into the right bucket, one stone at a time. What are you going to have to do?

    First, you have to take 1 stone from the left bucket, i.e. you are using sub1 to remove one stone from the bucket. You then add that same stone to the right bucket, i.e. you add1 to the right bucket.

    Now you could do this in a loop, but you don’t know how many stones there will be in any given solution. What you really want to do is say “Take one stone from the left bucket, put it in the right bucket and repeat until there are no stones in the left bucket.’ This case of there being no stones in the left bucket is called you “Base Case”. It’s the point at which you say OK, I’m done now.

    A pseudocode example of this situation would be (using your plus, add1, sub1 and zero):

    plus(leftBucket, rightBucket)
    {
      if(leftBucket == zero) // check if the left bucket is empty yet
      {
        // the left bucket is empty, we've moved all the stones
        return rightBucket; // the right bucket must be full
      }
      else 
      {
        // we still have stones in the left bucket, remove 1, 
        // put it in the right bucket, repeat.
        return plus(sub1(leftBucket), add1(rightBucket)); 
      }
    }
    

    If you still need more help, let me know, I can run through other examples but this looks like it’s probably a homework problem for you and recursion is incredibly important to understand so I don’t want to just give you all the answers.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.