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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:59:49+00:00 2026-06-14T09:59:49+00:00

I’m having a bit of trouble implementing this program in Scheme, although I think

  • 0

I’m having a bit of trouble implementing this program in Scheme, although I think I’m 90% of the way there. Unfortunately I need to be a little vague about it since this is a homework assignment.

I need to take one list as input, generate all possible subsequences of the list, and return ONE that matches a certain criteria. I have finished the code to generate all subsequences of the list and also to tell if a certain subset is a solution. I am however having trouble having Scheme return that solution. My code basically looks like this right now

(define (function rest_of_list subsequence)
    (if (subsequence is a solution) subsequence)
    (if (> (length rest_of_list) 0) (function (cdr rest_of_list) (append subsequence (car rest_of_list))))
    (if (> (length rest_of_list) 0) (function (cdr rest_of_list) subsequence)))

What this code should do is for each element in the list, it branches recursively in two directions. In one direction it adds (car rest_of_list) to subsequence and continues down the list. In the other direction it ignores (car rest_of_list) and continues down the list. As soon as it finds a subsequence that is acceptable, it returns it and that is the result of the function called function. Right now I just get blank output. And I sort of understand why I guess, but not well enough to fix this.

  • 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-14T09:59:50+00:00Added an answer on June 14, 2026 at 9:59 am

    It’s a bit tricky without looking at the exact details of your implementation, but I’d do something along these lines:

    (define (function rest_of_list subsequence)
      (cond ((null? rest_of_list)
             '())
            ((subsequence is a solution)
             subsequence)
            (else
             (combine (function (cdr rest_of_list) (append subsequence (car rest_of_list)))
                      (function (cdr rest_of_list) subsequence)))))
    

    The interesting part is how you combine both branches, it could be as simple as a cons. Also notice that a base case is probably missing: what happens if the rest of the list is null?

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
In my XML file chapters tag has more chapter tag.i need to display chapters
We're building an app, our first using Rails 3, and we're having to build

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.