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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:05:19+00:00 2026-05-25T03:05:19+00:00

Nested lists in Common Lisp really confused me. Here is the problem: By using

  • 0

Nested lists in Common Lisp really confused me. Here is the problem:

By using recursion, let (nested-list 'b '(a (b c) d)) return t
if the first argument appears in the second argument (which could be
a nested list), and nil otherwise.

I tried find, but it only works if the first argument is '(b c).
I turned my eyes on lambda expressions. I want to flatten the second
argument first, and then use eq to compare the arguments.

(defun nested-list (x y)
  (cond     
    ((null y) ())    
    (t (append (lambda (flatten) (first y))

Then I got stuck. Even though I read a lot of stuff about lambda
expessions, it still confused me. I do not know how to recall it when
I need, I knew the funcall function, but you know I just cannot get
it. I just learnt Common Lisp for 5 days, so I hope you can give me a
hint. Thanks a lot!

  • 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-25T03:05:20+00:00Added an answer on May 25, 2026 at 3:05 am

    First of all unless you mistyped if instead of iff the problem is quite trivial, just return t and you’re done 🙂

    Seriously speaking instead when you need to solve a problem using recursion the idea often is simply:

    1. if we’re in a trivial case just return the answer
    2. otherwise the answer is the same answer we’d get by solving a problem that it’s just a little bit simpler that this, and we call ourself to solve this simplified version.

    In the specific consider:

    1. If the second argument is an empty list the answer is NIL
    2. If the first argument is equal to the first element of the second argument then just return T instead
    3. Otherwise if the first element of the second list is a list (therefore also possibly a nested list) and the element is contained in this multilist then return true (to check this case the function is calling itself)
    4. Otherwise just check the same problem, but first dropping the first element of the second argument, because it has been checked (this also calls recursively the same function)

    So basically 1 and 2 are the trivial cases; 3 and 4 are the cases in which you solve a simpler version of the problem.

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

Sidebar

Related Questions

I can't figure out what is going on here. I have some nested lists
I have a nested list comprising ~30,000 sub-lists, each with three entries, e.g., nested_list
As per the title, I have a nested lists like so (the nested list
In Common Lisp you can do this: (defun foo (bar &key baz quux) (list
I am trying to build a navigation menu using nested lists, however whenever I
How to handle nested lists in Python? I am having problem figuring out the
I'm having trouble getting my head around a problem on recursive nested lists. The
How do you lazy load nested lists without actually executing the query? Using a
I have a problem with ie 7 and nested lists - this looks freaky
beginner to python here. I have 2 nested lists that I want to merge:

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.