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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:42:50+00:00 2026-05-26T16:42:50+00:00

I am trying to write a function that returns T/F in regards to if

  • 0

I am trying to write a function that returns T/F in regards to if a a list contains elements that are list(s) with exactly two elements which can be any expressions. I am pretty new to Scheme and have been stuck on how to determine how to go about doing this. I have tried everything from using if, cond, and lambda with no success. It seems I am having trouble figuring out how to have Scheme traverse through the entire list and returning whether it is T/F at the end.

Some examples of what I am looking for:

(foobar? '((a 1)(b 2)))
#t
(foobar? '((foo 100)(bar 2 3)))
#f
(foobar? '((a 1) b (c 3)))
#f
(foobar? '((a 1) . 2))
#f

Any help would be much appreciated.

  • 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-26T16:42:51+00:00Added an answer on May 26, 2026 at 4:42 pm
    1. Write a function has-two-elements? that determines whether a single list has exactly two elements. That shouldn’t be too hard.
    2. Write a recursive function all-have-two-elements? that determines whether all elements of a list are lists of exactly two elements. There are two cases to consider:

      • Base case: an empty list has no elements that do not have exactly two elements (since it’s doesn’t have any elements). So, you return #t.
      • Recursion: (has-two-elements? (car l)) and (all-have-two-elements? (cdr l)) must both be true.

    That’s seven lines of code if you indent properly.

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

Sidebar

Related Questions

I'm trying to write a function that takes multiple arguments, which can come either
I'm trying to write a function that returns an Array that I can pass
Trying to write function that numerize items of list and returns list of tuples
I'm trying to write a function that takes two string arguments and returns the
Trying to write a for function that takes two strings and returns the characters
I am trying to write a function that returns the index of the passed
I am trying to write a function that will filter a list of tuples
I'm trying to write a function that accepts a certain type or any of
I am trying to write a function that returns a one dimentional gauss filter.
Here I am trying to write a function that returns me value based on

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.