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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:51:40+00:00 2026-05-27T09:51:40+00:00

I asked several days ago about finding the most deeply nested lists . I

  • 0

I asked several days ago about finding the most deeply nested lists. I implemented the idea that was given, and it works.

But there is another problem: I also need to build a list from the nested list. meaning: If I change (8) and (10 11 12), to leaf1 and leaf2, I need to return: '(ans (leaf1 (8)) (leaf2 (10 11 12)). /ans is a quote

In other words:
my function will get
(1 (2 3) (4 (5) (7 (8) (10 11 12)))))) => the most nested lists are (8) and (10 11 12) => my function will return '(ans (leaf1 (8)) (leaf2 (10 11 12)).

I am trying to find an idea, not an implementation. Thanks.

  • 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-27T09:51:41+00:00Added an answer on May 27, 2026 at 9:51 am

    Yes, this is easy to do. Currently (if I understand correctly) you have a recursive function that descends a tree and uses cons to build a modified copy (in which the most deeply-nested lists are replaced with something). This is a common pattern for tree-recursive functions, but there’s no reason they have to return a value with a similar structure to the input they recur on. For example, you could write a function to walk a tree of numbers and return their sum.

    In this case it sounds like you probably want to keep the basic structure of your tree-recursive function, but use cons or possibly append to build a flat list of the most-deeply-nested-lists you’ve found.

    I can’t quite tell from your question, but you might also be looking for a way to write a function that returns two separate values: one being the tree with deeply-nested-lists replaced by something else, and the other being the flat list of the replaced bits themselves. In this case you might want to look into the Scheme procedures values and call-with-values, and maybe the library form let-values if your Scheme has it. See the Schemewiki FAQ here for more info (scroll down).

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

Sidebar

Related Questions

I've seen this asked in several ways but can't find an answer that works.
Small and pretty nasty problem I've seen several days ago, asked to my friend
Back in October, Kristopher Johnson asked about Accounting Software Design Patterns He received several
I asked here about a protocol that I was asked to implement, and how
I have asked several questions about Zend and its search functions. Now after further
I see that the question's been asked several times of how to set the
I'm really sorry, I realize there have been several questions asked about cocos2d touch
I can see that this question has been asked several times, but none of
I realize that this question may have been asked several times in the past,
I've come to realize that several questions I asked in the past, such as

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.